obfs: compatible with some server implementation in tls mode

This commit is contained in:
nadoo 2018-12-16 13:28:24 +08:00
parent 51fedc8653
commit 6ba9e1f5e8
5 changed files with 19 additions and 6 deletions

View File

@ -338,7 +338,7 @@ Examples:
- [transparent proxy with dnsmasq](config/examples/8.transparent_proxy_with_dnsmasq) - [transparent proxy with dnsmasq](config/examples/8.transparent_proxy_with_dnsmasq)
- [transparent proxy without dnsmasq](config/examples/9.transparent_proxy_without_dnsmasq) - [transparent proxy without dnsmasq](config/examples/9.transparent_proxy_without_dnsmasq)
### Forwarder Chain ### Proxy & Protocol Chain
In glider, you can easily chain several proxy servers or protocols together, e.g: In glider, you can easily chain several proxy servers or protocols together, e.g:
- Chain proxy servers: - Chain proxy servers:

View File

@ -32,7 +32,9 @@ func NewServer(addr string, dialer proxy.Dialer, config *Config) (*Server, error
return s, err return s, err
} }
// Start . // Start starts the dns forwarding server
// We use WaitGroup here to ensure both udp and tcp serer are completly running,
// so we can start any other services later, since they may rely on dns service.
func (s *Server) Start() { func (s *Server) Start() {
var wg sync.WaitGroup var wg sync.WaitGroup
wg.Add(2) wg.Add(2)

View File

@ -29,7 +29,7 @@ import (
) )
// VERSION . // VERSION .
const VERSION = "0.6.10" const VERSION = "0.6.11"
func main() { func main() {
// read configs // read configs

View File

@ -16,6 +16,7 @@ import (
"encoding/binary" "encoding/binary"
"io" "io"
"net" "net"
"time"
) )
const ( const (
@ -176,7 +177,17 @@ func clientHello() *bytes.Buffer {
// Random // Random
// https://tools.ietf.org/id/draft-mathewson-no-gmtunixtime-00.txt // https://tools.ietf.org/id/draft-mathewson-no-gmtunixtime-00.txt
random := make([]byte, 32) // NOTE:
// Most tls implementations do not deal with the first 4 bytes unix time,
// clients do not send current time, and server do not check it,
// golang tls client and chrome browser send random bytes instead.
//
binary.Write(buf, binary.BigEndian, uint32(time.Now().Unix()))
random := make([]byte, 28)
// The above 2 lines of codes was added to make it compatible with some server implementation,
// if we don't need the compatibility, just use the following code instead.
// random := make([]byte, 32)
rand.Read(random) rand.Read(random)
buf.Write(random) buf.Write(random)

View File

@ -132,10 +132,10 @@ func (d *Dialer) NextDialer(dstAddr string) proxy.Dialer {
return d.nextForwarder(dstAddr) return d.nextForwarder(dstAddr)
} }
// Priority returns the active priority of rrDialer // Priority returns the active priority of dialer
func (d *Dialer) Priority() uint32 { return atomic.LoadUint32(&d.priority) } func (d *Dialer) Priority() uint32 { return atomic.LoadUint32(&d.priority) }
// SetPriority sets the active priority of rrDialer // SetPriority sets the active priority of daler
func (d *Dialer) SetPriority(p uint32) { atomic.StoreUint32(&d.priority, p) } func (d *Dialer) SetPriority(p uint32) { atomic.StoreUint32(&d.priority, p) }
// initAvailable traverse d.fwdrs and init the available forwarder slice // initAvailable traverse d.fwdrs and init the available forwarder slice