
Security News
MCP Community Begins Work on Official MCP Metaregistry
The MCP community is launching an official registry to standardize AI tool discovery and let agents dynamically find and install MCP servers.
github.com/frobnitzem/go-p9p
A modern, performant 9P library for Go.
For API documentation, see the GoDoc.
Refer to 9P's documentation for more details on the protocol.
Download the package in the usual way:
go get github.com/frobnitzem/go-p9p
Now run the server and client. Since there's no authentication, it's safest to put it into a unix socket.
cd $HOME/go/frobnitzem/go-p9p
go run cmd/9ps/main.go -root $HOME/src -addr unix:/tmp/sock9 &
chmod 700 /tmp/sock9
go run cmd/9pr/main.go -addr unix:/tmp/sock9
You should get a prompt,
/ 🐳 >
There's actually a tab-autocomplete to show you commands to run.
Bring the server down with:
kill %
rm /tmp/sock9
To build a filesystem using this library, implement
the FileSys interface, and then pass it to SFileSys
.
For details on the FileSys interface, see filesys.go
.
For examples, see ufs/
and sleepfs/
subdirectories.
For a main program running the ufs server, see cmd/9fs/
.
In case you don't already have a 9p client, try cmd/9fr/
,
but note it is not full-featured.
Alternatively, if you want to implement a server that works
at a lower level of the stack, you can implement a Session
interface directly. See session.go
for the interface
definition and servefs.go
for an implementation at this level.
This package handles the 9P protocol by implementing a stack of layers. For the server, each layer does some incremental translation of the messages "on the wire" into program state. The client is opposite, translating function calls into wire representations, and invoking client callbacks with responses from the server.
Applications can pick one of the layers to interact with. Lower layers generally require more work on the applications side (tracking state, encoding messages, etc.). It's generally recommended to interface only with the uppermost layer's API.
Extending the layers upward to make even simpler interface API-s, as well as implementing proper authentication and session encryption is on the TODO list.
sfilesys.go: SFileSys(fs FileSys) Session
ssesssion.go: Dispatch(session Session) Handler
serveconn.go: ServeConn(ctx context.Context, cn net.Conn, handler Handler) error
serverconn.go: (c *conn) serve() error
cfilesys.go: CFileSys(session Session) FileSys
// Note: we could make into CSession(Handler) (Session, error)
client.go: CSession(ctx context.Context, conn net.Conn) (Session, error)
transport.go: func newTransport(ctx context.Context, ch Channel) roundTripper
handle
goroutine to take messages off the wire
and invoke waiting response actions in the client.channel.go: NewChannel(conn net.Conn, msize int) Channel
channel.go: (ch *channel) WriteFcall(ctx context.Context, fcall *Fcall) error
channel.go: channel.go: (ch *channel) ReadFcall(ctx context.Context, fcall *Fcall) error
messages.go: newMessage(typ FcallType) (Message, error)
encoding.go: interface Codec
[]byte
and 9P message structs.The server auto-generates calls to File.Close(). This function does nothing on the client side (use Clunk instead).
The client qids = Walk(names...)
returns an Error/Warning when
Walk returns a partial, incomplete walk to the destination.
This happens if len(names) > 1 and walk returns len(qids) != len(names).
Lookup a Fid:
Clunk/Remove a Fid:
Auth:
Attach:
Note: Rather than using a locked fid lookup table, we could have the dispatcher do fid lookups, and send requests on a channel dedicated to (a goroutine) serving only that fid. This may be an optimization, or it may not - only lots of work and profiling will tell. So, this has not been tried.
Copyright © 2015 Docker, Inc. Copyright © 2023 UT-Battelle LLC. go-p9p is licensed under the Apache License, Version 2.0. See LICENSE for the full license text.
FAQs
Unknown package
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
The MCP community is launching an official registry to standardize AI tool discovery and let agents dynamically find and install MCP servers.
Research
Security News
Socket uncovers an npm Trojan stealing crypto wallets and BullX credentials via obfuscated code and Telegram exfiltration.
Research
Security News
Malicious npm packages posing as developer tools target macOS Cursor IDE users, stealing credentials and modifying files to gain persistent backdoor access.