Add (optional) strict version checking (#58)

master
HimbeerserverDE 2021-03-29 22:20:12 +02:00
parent 6b3b5fcd85
commit 529fcba729
No known key found for this signature in database
GPG Key ID: 1A651504791E6A8B
2 changed files with 9 additions and 3 deletions

View File

@ -134,6 +134,12 @@ Type: Boolean
Description: Whether to allow clients to use modchannels,
default is true
```
> `force_latest_proto`
```
Type: Boolean
Description: Whether to force clients to use the latest protocol version,
default is false
```
> `serverlist_url`
```
Type: String

View File

@ -15,8 +15,7 @@ import (
"github.com/anon55555/mt/rudp"
)
// Init authenticates to the server srv
// and finishes the initialisation process if ignMedia is true
// Init completes the initialisation of a connection to a server or client c2
func Init(c, c2 *Conn, ignMedia, noAccessDenied bool, fin chan *Conn) {
defer close(fin)
@ -267,6 +266,7 @@ func Init(c, c2 *Conn, ignMedia, noAccessDenied bool, fin chan *Conn) {
}
}
} else {
// We're trying to initialize a client
for {
pkt, err := c2.Recv()
if err != nil {
@ -325,7 +325,7 @@ func Init(c, c2 *Conn, ignMedia, noAccessDenied bool, fin chan *Conn) {
c2.protoVer = protov
if protov < ProtoMin || protov > ProtoLatest {
if strict, ok := ConfKey("force_latest_proto").(bool); (ok && strict) && (protov != ProtoLatest) || protov < ProtoMin || protov > ProtoLatest {
data := []byte{
0, ToClientAccessDenied,
AccessDeniedWrongVersion, 0, 0, 0, 0,