fea: ceci name proxy support.

This commit is contained in:
Daniel Ding
2025-04-17 11:53:22 +08:00
parent 522733592b
commit 32bd526dec
15 changed files with 276 additions and 90 deletions

View File

@@ -4,7 +4,6 @@ import (
"flag"
"os"
"github.com/luscis/openlan/pkg/access"
"github.com/luscis/openlan/pkg/config"
"github.com/luscis/openlan/pkg/libol"
"github.com/luscis/openlan/pkg/proxy"
@@ -13,10 +12,17 @@ import (
func main() {
mode := "http"
conf := ""
nodate := false
flag.StringVar(&mode, "mode", "http", "Proxy mode for http, socks, tcp and name")
flag.StringVar(&conf, "conf", "ceci.yaml", "The configuration file")
flag.BoolVar(&nodate, "nodate", nodate, "Dont display message datetime")
flag.Parse()
if nodate {
libol.NoLogDate()
}
if !(mode == "http" || mode == "socks" || mode == "tcp" || mode == "name") {
libol.Warn("Ceci: not support mode:%s", mode)
os.Exit(1)
@@ -24,41 +30,35 @@ func main() {
libol.PreNotify()
var x proxy.Proxyer
if mode == "name" {
c := &config.Point{
RequestAddr: true,
Terminal: "off",
Conf: conf,
}
c := &config.NameProxy{Conf: conf}
if err := c.Initialize(); err != nil {
return
}
p := access.NewPoint(c)
p.Initialize()
libol.Go(p.Start)
x = proxy.NewNameProxy(c)
} else if mode == "socks" {
c := &config.SocksProxy{Conf: conf}
if err := c.Initialize(); err != nil {
return
}
p := proxy.NewSocksProxy(c)
libol.Go(p.Start)
x = proxy.NewSocksProxy(c)
} else if mode == "tcp" {
c := &config.TcpProxy{Conf: conf}
if err := c.Initialize(); err != nil {
return
}
p := proxy.NewTcpProxy(c)
libol.Go(p.Start)
x = proxy.NewTcpProxy(c)
} else {
c := &config.HttpProxy{Conf: conf}
if err := c.Initialize(); err != nil {
return
}
p := proxy.NewHttpProxy(c, nil)
libol.Go(p.Start)
x = proxy.NewHttpProxy(c, nil)
}
libol.Go(x.Start)
libol.SdNotify()
libol.Wait()
x.Stop()
}