Unexport some client.State fields

This commit is contained in:
Andy Wang 2019-08-17 00:18:19 +01:00
parent b98a74f49b
commit 812ca1af99
3 changed files with 9 additions and 9 deletions

View File

@ -8,7 +8,7 @@ import (
log "github.com/sirupsen/logrus" log "github.com/sirupsen/logrus"
) )
type Browser interface { type browser interface {
composeClientHello(chHiddenData) []byte composeClientHello(chHiddenData) []byte
} }
@ -39,7 +39,7 @@ func addExtRec(typ []byte, data []byte) []byte {
func PrepareConnection(sta *State, conn net.Conn) (sessionKey []byte, err error) { func PrepareConnection(sta *State, conn net.Conn) (sessionKey []byte, err error) {
hd, sharedSecret := makeHiddenData(sta) hd, sharedSecret := makeHiddenData(sta)
chOnly := sta.Browser.composeClientHello(hd) chOnly := sta.browser.composeClientHello(hd)
chWithRecordLayer := util.AddRecordLayer(chOnly, []byte{0x16}, []byte{0x03, 0x01}) chWithRecordLayer := util.AddRecordLayer(chOnly, []byte{0x16}, []byte{0x03, 0x01})
_, err = conn.Write(chWithRecordLayer) _, err = conn.Write(chWithRecordLayer)
if err != nil { if err != nil {

View File

@ -29,7 +29,7 @@ func makeHiddenData(sta *State) (ret chHiddenData, sharedSecret []byte) {
copy(plaintext, sta.UID) copy(plaintext, sta.UID)
copy(plaintext[16:28], sta.ProxyMethod) copy(plaintext[16:28], sta.ProxyMethod)
plaintext[28] = sta.EncryptionMethod plaintext[28] = sta.EncryptionMethod
binary.BigEndian.PutUint64(plaintext[29:37], uint64(sta.Now().Unix())) binary.BigEndian.PutUint64(plaintext[29:37], uint64(sta.now().Unix()))
binary.BigEndian.PutUint32(plaintext[37:41], atomic.LoadUint32(&sta.SessionID)) binary.BigEndian.PutUint32(plaintext[37:41], atomic.LoadUint32(&sta.SessionID))
if sta.Unordered { if sta.Unordered {

View File

@ -30,12 +30,12 @@ type State struct {
RemotePort string RemotePort string
Unordered bool Unordered bool
Now func() time.Time
SessionID uint32 SessionID uint32
UID []byte UID []byte
staticPub crypto.PublicKey
Browser Browser staticPub crypto.PublicKey
now func() time.Time
browser browser
ProxyMethod string ProxyMethod string
EncryptionMethod byte EncryptionMethod byte
@ -49,7 +49,7 @@ func InitState(localHost, localPort, remoteHost, remotePort string, nowFunc func
LocalPort: localPort, LocalPort: localPort,
RemoteHost: remoteHost, RemoteHost: remoteHost,
RemotePort: remotePort, RemotePort: remotePort,
Now: nowFunc, now: nowFunc,
} }
return ret return ret
} }
@ -114,9 +114,9 @@ func (sta *State) ParseConfig(conf string) (err error) {
switch strings.ToLower(preParse.BrowserSig) { switch strings.ToLower(preParse.BrowserSig) {
case "chrome": case "chrome":
sta.Browser = &Chrome{} sta.browser = &Chrome{}
case "firefox": case "firefox":
sta.Browser = &Firefox{} sta.browser = &Firefox{}
default: default:
return errors.New("unsupported browser signature") return errors.New("unsupported browser signature")
} }