Documentation ¶
Index ¶
- Constants
- func GetFeedRefFromAddr(addr net.Addr) (*refs.FeedRef, error)
- type ConnTracker
- type EndpointStat
- type Endpoints
- type Network
- type Options
- type ServerEndpointDetails
- type WebsockConn
- func (conn *WebsockConn) Close() error
- func (conn *WebsockConn) LocalAddr() net.Addr
- func (conn *WebsockConn) Read(data []byte) (int, error)
- func (conn *WebsockConn) RemoteAddr() net.Addr
- func (conn *WebsockConn) SetDeadline(t time.Time) error
- func (conn *WebsockConn) SetReadDeadline(t time.Time) error
- func (conn *WebsockConn) SetWriteDeadline(t time.Time) error
- func (conn *WebsockConn) Write(data []byte) (int, error)
Constants ¶
const DefaultPort = 8008
DefaultPort is the default listening port for ScuttleButt.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type ConnTracker ¶
type ConnTracker interface { // Active returns true and since when a peer connection is active Active(net.Addr) (bool, time.Duration) // OnAccept receives a new connection as an argument. // If it decides to accept it, it returns true and a context that will be canceled once it should shut down // If it decides to deny it, it returns false (and a nil context) OnAccept(context.Context, net.Conn) (bool, context.Context) // OnClose notifies the tracker that a connection was closed OnClose(conn net.Conn) time.Duration // Count returns the number of open connections Count() uint // CloseAll closes all tracked connections CloseAll() }
ConnTracker decides if connections should be established and keeps track of them
func NewAcceptAllTracker ¶
func NewAcceptAllTracker() ConnTracker
This just keeps a count and doesn't actually track anything
func NewConnTracker ¶
func NewConnTracker() ConnTracker
func NewLastWinsTracker ¶
func NewLastWinsTracker() ConnTracker
NewLastWinsTracker returns a conntracker that just kills the previous connection and let's the new one in.
type EndpointStat ¶
type EndpointStat struct { ID *refs.FeedRef Addr net.Addr Since time.Duration Endpoint muxrpc.Endpoint }
EndpointStat gives some information about a connected peer
type Endpoints ¶
Endpoints returns the connected endpoint for the passed feed, or false if there is none.
type Network ¶
type Network interface { Connect(ctx context.Context, addr net.Addr) error Serve(context.Context, ...muxrpc.HandlerWrapper) error GetListenAddr() net.Addr GetAllEndpoints() []EndpointStat Endpoints GetConnTracker() ConnTracker // WebsockHandler returns a "middleware" like thing that is able to upgrade a // websocket request to a muxrpc connection and authenticate using shs. // It calls the next handler if it fails to upgrade the connection to websocket. // However, it will error on the request and not call the passed handler // if the websocket upgrade is successfull. WebsockHandler(next http.Handler) http.Handler io.Closer }
Network supplies all network related functionalitiy
type Options ¶
type Options struct { Logger log.Logger Dialer netwrap.Dialer ListenAddr net.Addr KeyPair *keys.KeyPair AppKey []byte MakeHandler func(net.Conn) (muxrpc.Handler, error) ConnTracker ConnTracker // PreSecureWrappers are applied before the shs+boxstream wrapping takes place // usefull for accessing the sycall.Conn to apply control options on the socket BefreCryptoWrappers []netwrap.ConnWrapper // AfterSecureWrappers are applied afterwards, usefull to debug muxrpc content AfterSecureWrappers []netwrap.ConnWrapper }
type ServerEndpointDetails ¶
type ServerEndpointDetails struct { RoomID refs.FeedRef ListenAddressMUXRPC string // defaults to ":8008" // Domain sets the DNS name for all the HTTP(S) URLs. Domain string PortHTTPS uint // 0 assumes default (443) // UseSubdomainForAliases controls wether urls for alias resolving // are generated as https://$alias.$domain instead of https://$domain/alias/$alias UseSubdomainForAliases bool // Development instructs url building to happen with http and include the http port Development bool }
ServerEndpointDetails encapsulates the endpoint information. Like domain name of the room, it's ssb/secret-handshake public key and the HTTP and MUXRPC TCP ports.
func (ServerEndpointDetails) MultiserverAddress ¶
func (sed ServerEndpointDetails) MultiserverAddress() string
MultiserverAddress returns net:domain:muxport~shs:roomPubKeyInBase64 ie: the room servers https://github.com/ssbc/multiserver-address
func (ServerEndpointDetails) URLForAlias ¶
func (sed ServerEndpointDetails) URLForAlias(a string) string
type WebsockConn ¶
type WebsockConn struct {
// contains filtered or unexported fields
}
WebsockConn emulates a normal net.Conn from a websocket connection
func NewWebsockConn ¶
func NewWebsockConn(wsc *websocket.Conn) *WebsockConn
func (*WebsockConn) Close ¶
func (conn *WebsockConn) Close() error
func (*WebsockConn) LocalAddr ¶
func (conn *WebsockConn) LocalAddr() net.Addr
func (*WebsockConn) RemoteAddr ¶
func (conn *WebsockConn) RemoteAddr() net.Addr
func (*WebsockConn) SetDeadline ¶
func (conn *WebsockConn) SetDeadline(t time.Time) error
func (*WebsockConn) SetReadDeadline ¶
func (conn *WebsockConn) SetReadDeadline(t time.Time) error
func (*WebsockConn) SetWriteDeadline ¶
func (conn *WebsockConn) SetWriteDeadline(t time.Time) error