mirror of
https://github.com/octoleo/syncthing.git
synced 2025-02-02 11:58:28 +00:00
Add RelayFull message
This commit is contained in:
parent
92158b0611
commit
9047d56aa0
@ -119,6 +119,10 @@ func (c *staticClient) Serve() {
|
|||||||
}
|
}
|
||||||
c.invitations <- msg
|
c.invitations <- msg
|
||||||
|
|
||||||
|
case protocol.RelayFull:
|
||||||
|
l.Infoln("Disconnected from relay due to it becoming full.")
|
||||||
|
return
|
||||||
|
|
||||||
default:
|
default:
|
||||||
l.Infoln("Relay: protocol error: unexpected message %v", msg)
|
l.Infoln("Relay: protocol error: unexpected message %v", msg)
|
||||||
return
|
return
|
||||||
@ -240,6 +244,9 @@ func (c *staticClient) join() error {
|
|||||||
return fmt.Errorf("Incorrect response code %d: %s", msg.Code, msg.Message)
|
return fmt.Errorf("Incorrect response code %d: %s", msg.Code, msg.Message)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
case protocol.RelayFull:
|
||||||
|
return fmt.Errorf("relay full")
|
||||||
|
|
||||||
default:
|
default:
|
||||||
return fmt.Errorf("protocol error: expecting response got %v", msg)
|
return fmt.Errorf("protocol error: expecting response got %v", msg)
|
||||||
}
|
}
|
||||||
|
@ -20,6 +20,7 @@ const (
|
|||||||
messageTypeResponse
|
messageTypeResponse
|
||||||
messageTypeConnectRequest
|
messageTypeConnectRequest
|
||||||
messageTypeSessionInvitation
|
messageTypeSessionInvitation
|
||||||
|
messageTypeRelayFull
|
||||||
)
|
)
|
||||||
|
|
||||||
type header struct {
|
type header struct {
|
||||||
@ -31,6 +32,7 @@ type header struct {
|
|||||||
type Ping struct{}
|
type Ping struct{}
|
||||||
type Pong struct{}
|
type Pong struct{}
|
||||||
type JoinRelayRequest struct{}
|
type JoinRelayRequest struct{}
|
||||||
|
type RelayFull struct{}
|
||||||
|
|
||||||
type JoinSessionRequest struct {
|
type JoinSessionRequest struct {
|
||||||
Key []byte // max:32
|
Key []byte // max:32
|
||||||
|
@ -256,6 +256,63 @@ func (o *JoinRelayRequest) DecodeXDRFrom(xr *xdr.Reader) error {
|
|||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
||||||
|
RelayFull Structure:
|
||||||
|
|
||||||
|
0 1 2 3
|
||||||
|
0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
|
||||||
|
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
||||||
|
|
||||||
|
|
||||||
|
struct RelayFull {
|
||||||
|
}
|
||||||
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
func (o RelayFull) EncodeXDR(w io.Writer) (int, error) {
|
||||||
|
var xw = xdr.NewWriter(w)
|
||||||
|
return o.EncodeXDRInto(xw)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (o RelayFull) MarshalXDR() ([]byte, error) {
|
||||||
|
return o.AppendXDR(make([]byte, 0, 128))
|
||||||
|
}
|
||||||
|
|
||||||
|
func (o RelayFull) MustMarshalXDR() []byte {
|
||||||
|
bs, err := o.MarshalXDR()
|
||||||
|
if err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
return bs
|
||||||
|
}
|
||||||
|
|
||||||
|
func (o RelayFull) AppendXDR(bs []byte) ([]byte, error) {
|
||||||
|
var aw = xdr.AppendWriter(bs)
|
||||||
|
var xw = xdr.NewWriter(&aw)
|
||||||
|
_, err := o.EncodeXDRInto(xw)
|
||||||
|
return []byte(aw), err
|
||||||
|
}
|
||||||
|
|
||||||
|
func (o RelayFull) EncodeXDRInto(xw *xdr.Writer) (int, error) {
|
||||||
|
return xw.Tot(), xw.Error()
|
||||||
|
}
|
||||||
|
|
||||||
|
func (o *RelayFull) DecodeXDR(r io.Reader) error {
|
||||||
|
xr := xdr.NewReader(r)
|
||||||
|
return o.DecodeXDRFrom(xr)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (o *RelayFull) UnmarshalXDR(bs []byte) error {
|
||||||
|
var br = bytes.NewReader(bs)
|
||||||
|
var xr = xdr.NewReader(br)
|
||||||
|
return o.DecodeXDRFrom(xr)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (o *RelayFull) DecodeXDRFrom(xr *xdr.Reader) error {
|
||||||
|
return xr.Error()
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
|
||||||
JoinSessionRequest Structure:
|
JoinSessionRequest Structure:
|
||||||
|
|
||||||
0 1 2 3
|
0 1 2 3
|
||||||
|
@ -50,6 +50,9 @@ func WriteMessage(w io.Writer, message interface{}) error {
|
|||||||
case SessionInvitation:
|
case SessionInvitation:
|
||||||
payload, err = msg.MarshalXDR()
|
payload, err = msg.MarshalXDR()
|
||||||
header.messageType = messageTypeSessionInvitation
|
header.messageType = messageTypeSessionInvitation
|
||||||
|
case RelayFull:
|
||||||
|
payload, err = msg.MarshalXDR()
|
||||||
|
header.messageType = messageTypeRelayFull
|
||||||
default:
|
default:
|
||||||
err = fmt.Errorf("Unknown message type")
|
err = fmt.Errorf("Unknown message type")
|
||||||
}
|
}
|
||||||
@ -108,6 +111,10 @@ func ReadMessage(r io.Reader) (interface{}, error) {
|
|||||||
var msg SessionInvitation
|
var msg SessionInvitation
|
||||||
err := msg.DecodeXDR(r)
|
err := msg.DecodeXDR(r)
|
||||||
return msg, err
|
return msg, err
|
||||||
|
case messageTypeRelayFull:
|
||||||
|
var msg RelayFull
|
||||||
|
err := msg.DecodeXDR(r)
|
||||||
|
return msg, err
|
||||||
}
|
}
|
||||||
|
|
||||||
return nil, fmt.Errorf("Unknown message type")
|
return nil, fmt.Errorf("Unknown message type")
|
||||||
|
Loading…
x
Reference in New Issue
Block a user