* implement authentication via token for relaysrv Make replaysrv check for a token before allowing clients to join. The token can be set via the replay-uri. * fix formatting * key composite literal * do not error out if auth material is provided but not needed * remove unused method receiver * clean up unused parameter in functions * cleaner token handling, disable joining the pool if token is set. * Keep backwards compatibility with older clients. In prior versions of the protocol JoinRelayRequest did not have a token field. Trying to unmarshal such a request will result in an error. Return an empty JoinRelayRequest, that is a request without token, instead. Co-authored-by: entity0xfe <entity0xfe@my.domain>
This commit is contained in:
@@ -137,40 +137,6 @@ func (*Pong) UnmarshalXDRFrom(_ *xdr.Unmarshaller) error {
|
||||
|
||||
/*
|
||||
|
||||
JoinRelayRequest Structure:
|
||||
(contains no fields)
|
||||
|
||||
|
||||
struct JoinRelayRequest {
|
||||
}
|
||||
|
||||
*/
|
||||
|
||||
func (JoinRelayRequest) XDRSize() int {
|
||||
return 0
|
||||
}
|
||||
func (JoinRelayRequest) MarshalXDR() ([]byte, error) {
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
func (JoinRelayRequest) MustMarshalXDR() []byte {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (JoinRelayRequest) MarshalXDRInto(_ *xdr.Marshaller) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (*JoinRelayRequest) UnmarshalXDR(_ []byte) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (*JoinRelayRequest) UnmarshalXDRFrom(_ *xdr.Unmarshaller) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
RelayFull Structure:
|
||||
(contains no fields)
|
||||
|
||||
@@ -205,6 +171,57 @@ func (*RelayFull) UnmarshalXDRFrom(_ *xdr.Unmarshaller) error {
|
||||
|
||||
/*
|
||||
|
||||
JoinRelayRequest 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
|
||||
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
||||
/ /
|
||||
\ Token (length + padded data) \
|
||||
/ /
|
||||
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
||||
|
||||
|
||||
struct JoinRelayRequest {
|
||||
string Token<>;
|
||||
}
|
||||
|
||||
*/
|
||||
|
||||
func (o JoinRelayRequest) XDRSize() int {
|
||||
return 4 + len(o.Token) + xdr.Padding(len(o.Token))
|
||||
}
|
||||
|
||||
func (o JoinRelayRequest) MarshalXDR() ([]byte, error) {
|
||||
buf := make([]byte, o.XDRSize())
|
||||
m := &xdr.Marshaller{Data: buf}
|
||||
return buf, o.MarshalXDRInto(m)
|
||||
}
|
||||
|
||||
func (o JoinRelayRequest) MustMarshalXDR() []byte {
|
||||
bs, err := o.MarshalXDR()
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return bs
|
||||
}
|
||||
|
||||
func (o JoinRelayRequest) MarshalXDRInto(m *xdr.Marshaller) error {
|
||||
m.MarshalString(o.Token)
|
||||
return m.Error
|
||||
}
|
||||
|
||||
func (o *JoinRelayRequest) UnmarshalXDR(bs []byte) error {
|
||||
u := &xdr.Unmarshaller{Data: bs}
|
||||
return o.UnmarshalXDRFrom(u)
|
||||
}
|
||||
func (o *JoinRelayRequest) UnmarshalXDRFrom(u *xdr.Unmarshaller) error {
|
||||
o.Token = u.UnmarshalString()
|
||||
return u.Error
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
JoinSessionRequest Structure:
|
||||
|
||||
0 1 2 3
|
||||
|
||||
Reference in New Issue
Block a user