|
|
@ -2,7 +2,6 @@ package client
|
|
|
|
|
|
|
|
|
|
|
|
import (
|
|
|
|
import (
|
|
|
|
"crypto"
|
|
|
|
"crypto"
|
|
|
|
"encoding/base64"
|
|
|
|
|
|
|
|
"encoding/json"
|
|
|
|
"encoding/json"
|
|
|
|
"errors"
|
|
|
|
"errors"
|
|
|
|
"io/ioutil"
|
|
|
|
"io/ioutil"
|
|
|
@ -18,8 +17,8 @@ type rawConfig struct {
|
|
|
|
ServerName string
|
|
|
|
ServerName string
|
|
|
|
ProxyMethod string
|
|
|
|
ProxyMethod string
|
|
|
|
EncryptionMethod string
|
|
|
|
EncryptionMethod string
|
|
|
|
UID string
|
|
|
|
UID []byte
|
|
|
|
PublicKey string
|
|
|
|
PublicKey []byte
|
|
|
|
BrowserSig string
|
|
|
|
BrowserSig string
|
|
|
|
Transport string
|
|
|
|
Transport string
|
|
|
|
NumConn int
|
|
|
|
NumConn int
|
|
|
@ -131,21 +130,13 @@ func (sta *State) ParseConfig(conf string) (err error) {
|
|
|
|
sta.ServerName = preParse.ServerName
|
|
|
|
sta.ServerName = preParse.ServerName
|
|
|
|
sta.NumConn = preParse.NumConn
|
|
|
|
sta.NumConn = preParse.NumConn
|
|
|
|
sta.Timeout = time.Duration(preParse.StreamTimeout) * time.Second
|
|
|
|
sta.Timeout = time.Duration(preParse.StreamTimeout) * time.Second
|
|
|
|
|
|
|
|
sta.UID = preParse.UID
|
|
|
|
|
|
|
|
|
|
|
|
uid, err := base64.StdEncoding.DecodeString(preParse.UID)
|
|
|
|
pub, ok := ecdh.Unmarshal(preParse.PublicKey)
|
|
|
|
if err != nil {
|
|
|
|
|
|
|
|
return errors.New("Failed to parse UID: " + err.Error())
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
sta.UID = uid
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
pubBytes, err := base64.StdEncoding.DecodeString(preParse.PublicKey)
|
|
|
|
|
|
|
|
if err != nil {
|
|
|
|
|
|
|
|
return errors.New("Failed to parse Public key: " + err.Error())
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
pub, ok := ecdh.Unmarshal(pubBytes)
|
|
|
|
|
|
|
|
if !ok {
|
|
|
|
if !ok {
|
|
|
|
return errors.New("Failed to unmarshal Public key")
|
|
|
|
return errors.New("Failed to unmarshal Public key")
|
|
|
|
}
|
|
|
|
}
|
|
|
|
sta.staticPub = pub
|
|
|
|
sta.staticPub = pub
|
|
|
|
|
|
|
|
|
|
|
|
return nil
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
}
|
|
|
|