check mtu setting

pull/215/head
v2ray 2016-06-18 17:14:39 +02:00
parent 16f5f81fe9
commit a0d08e4961
1 changed files with 8 additions and 0 deletions

View File

@ -4,6 +4,9 @@ package kcp
import (
"encoding/json"
"errors"
"github.com/v2ray/v2ray-core/common/log"
)
func (this *Config) UnmarshalJSON(data []byte) error {
@ -15,6 +18,11 @@ func (this *Config) UnmarshalJSON(data []byte) error {
return err
}
if jsonConfig.Mtu != nil {
mtu := *jsonConfig.Mtu
if mtu < 576 || mtu > 1460 {
log.Error("KCP|Config: Invalid MTU size: ", mtu)
return errors.New("Invalid configuration")
}
this.Mtu = *jsonConfig.Mtu
}