diff --git a/http.go b/http.go index 898c0c2..10d259a 100644 --- a/http.go +++ b/http.go @@ -24,7 +24,8 @@ type HTTP struct { user string password string - xff bool + xff bool // X-Forwarded-For + xsi bool // X-Server-IP selfip string } @@ -47,6 +48,12 @@ func NewHTTP(addr, user, pass, rawQuery string, cDialer Dialer, sDialer Dialer) } } + if v, ok := p["xsi"]; ok { + if v[0] == "true" { + s.xsi = true + } + } + return s, nil } @@ -166,13 +173,8 @@ func (s *HTTP) Serve(c net.Conn) { respHeader.Set("Proxy-Connection", "close") respHeader.Set("Connection", "close") - if s.xff { - if respHeader.Get("X-Forwarded-For") != "" { - respHeader.Add("X-Forwarded-For", ",") - } - respHeader.Add("X-Forwarded-For", rc.RemoteAddr().(*net.TCPAddr).IP.String()) - respHeader.Add("X-Forwarded-For", ",") - respHeader.Add("X-Forwarded-For", s.selfip) + if s.xsi { + respHeader.Set("X-Server-IP", rc.RemoteAddr().(*net.TCPAddr).IP.String()) } var respBuf bytes.Buffer diff --git a/systemd/glider@.service b/systemd/glider@.service index 399292a..2b7d464 100644 --- a/systemd/glider@.service +++ b/systemd/glider@.service @@ -1,6 +1,7 @@ [Unit] Description=Glider Service (%i) After=network.target +Before=iptables.service ip6tables.service [Service] Type=simple diff --git a/uottun.go b/uottun.go index a87c886..fcd05e0 100644 --- a/uottun.go +++ b/uottun.go @@ -48,24 +48,22 @@ func (s *UoTTun) ListenAndServe() { rc, err := s.sDialer.Dial("uot", s.raddr) if err != nil { logf("proxy-uottun failed to connect to server %v: %v", s.raddr, err) - return + continue } rc.Write(buf[:n]) // no remote forwarder, just a local udp forwarder if urc, ok := rc.(*net.UDPConn); ok { - go func() { timedCopy(c, clientAddr, urc, 5*time.Minute, false) urc.Close() }() - } else { // remote forwarder, udp over tcp resp, err := ioutil.ReadAll(rc) if err != nil { logf("error in ioutil.ReadAll: %s\n", err) - return + continue } rc.Close() c.WriteTo(resp, clientAddr)