Git Product home page Git Product logo

smbapi's Introduction

SMB2

!!! NOT MAINTEN

A Go package for smb server.

Currently test pass with iphone files.

mac 12.6.8

Here is a sample code from smb server:

var config *smb.Config

func init() {
	Logger := func(r *http.Request, err error) {
		if err != nil { 
		} else { 
		}
	}

	pwd := util.PWDR()
	anchor1 := smb.NewAnchor("TestDir1", pwd)
	anchor2 := smb.NewAnchor("TestDir2", pwd)

	config = &smb.Config{
		Pwd: func(name string) (string, error) {
			if UserName == name || name == "apple" {
				return UserPwd, nil
			}
			return "", fmt.Errorf("not found")
		},
		Tree: func(userName string) ([]*smb.Anchor, error) {
			anchorIPC := smb.NewAnchor(smb.NamedPipeShareName, pwd)
			return []*smb.Anchor{
				anchor1,
				anchor2,
				anchorIPC,
			}, nil
		},
		Handle: func(path string) *smb.Handler {
			return &smb.Handler{
				&webdav.Handler{
					Logger:     Logger,
					Prefix:     "/" + anchor1.Name + "/",
					FileSystem: webdav.Dir("/"),
					LockSystem: webdav.NewMemLS(),
				},
			}
		},
	}
}

ser := smb.NewServer(config)
go ser.Start(445)

smbapi's People

Contributors

izouxv avatar jjm2473 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

smbapi's Issues

Unable to authenticate using Windows File Explorer

While I am testing this library I encountered the following error on Linux (Debian)

IP: 192.168.1.214:600132024/01/13 23:09:35 [ DEBUG ]  Negotiating protocol
2024/01/13 23:09:35 [ DEBUG ]  Sending NegotiateProtocolServer2 request
2024-01-13 23:09:35.896037      INFO    smb/session_ser.go:315  [CMD] cmd, CommandNegotiate
clientSupportDialect: [514 528 768 770 785]2024-01-13 23:09:35.89672    INFO    smb/session_ser.go:315  [CMD] cmd, CommandSessionSetup
2024/01/13 23:09:35 [ DEBUG ]
2024-01-13 23:09:35.897107      ERROR   smb/session_ser.go:142  requestSetUp2, err: read tcp 192.168.1.154:445->192.168.1.214:60013: read: connection reset by peer
2024-01-13 23:09:35.897191      INFO    smb/server.go:99        login failed, false, err: read tcp 192.168.1.154:445->192.168.1.214:60013: read: connection reset by peer

I have migrated the library into a separate repo as there are typo in the go.mod file module defination

module github/izouxv/smbapi

instead of

module github.com/izouxv/smbapi

which make it impossible to use with go get command.

After migration, I saw the above error when deploying a test server using the example script in a Debian VM environment and try to connect to it using Windows 10 File Explorer. The username and password are both correct and when Windows try to connect to it, it always shows connection reset by peer error.

圖片
The password request dialog is correctly shown though, so I guess there might be issue with the way how the library handle the authentication.

I am trying to debug this by tracing down the NegotiateProtocolServer() function but after some modification I still cant get it working.

Any help will be grateful, thanks for the great work!

iphone 文件无法复制

在iphone上,文件这个App通过SMB与服务记录连接后,无法执行基本的复制相关的操作。

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.