chore(systemd): use DynamicUser

This commit is contained in:
nadoo committed 2021-12-20 22:41:44 +08:00
1 parent b502b129b7
commit 826695df9a
5 files changed
+20 -46

No files matched your search

+2 -2
View File
@@ -42,13 +42,13 @@ func (s *HTTP) ListenAndServe() {
// Serve serves a connection.
func (s *HTTP) Serve(cc net.Conn) {
defer cc.Close()
if c, ok := cc.(*net.TCPConn); ok {
c.SetKeepAlive(true)
}
c := proxy.NewConn(cc)
defer c.Close()
req, err := parseRequest(c.Reader())
if err != nil {
log.F("[http] can not parse request from %s, error: %v", c.RemoteAddr(), err)
+5 -31
View File
@@ -1,7 +1,6 @@
package mixed
import (
"bytes"
"net"
"net/url"
@@ -80,37 +79,12 @@ func (m *Mixed) ListenAndServe() {
// Serve serves connections.
func (m *Mixed) Serve(c net.Conn) {
defer c.Close()
if c, ok := c.(*net.TCPConn); ok {
c.SetKeepAlive(true)
}
cc := proxy.NewConn(c)
head, err := cc.Peek(1)
if err != nil {
// log.F("[mixed] socks5 peek error: %s", err)
return
}
// check socks5, client send socksversion: 5 as the first byte
if head[0] == socks5.Version {
m.socks5Server.Serve(cc)
return
}
head, err = cc.Peek(8)
if err != nil {
log.F("[mixed] http peek error: %s", err)
return
}
for _, method := range http.Methods {
if bytes.HasPrefix(head, method) {
m.httpServer.Serve(cc)
conn := proxy.NewConn(c)
if head, err := conn.Peek(1); err == nil {
if head[0] == socks5.Version {
m.socks5Server.Serve(conn)
return
}
}
log.F("[mixed] unknown request from %s, ignored", c.RemoteAddr())
m.httpServer.Serve(conn)
}