mirror of
https://github.com/luscis/openlan.git
synced 2025-10-17 06:20:40 +08:00
fea: openacce for ceci name.
This commit is contained in:
@@ -2,6 +2,7 @@ package main
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"flag"
|
"flag"
|
||||||
|
"os"
|
||||||
|
|
||||||
"github.com/luscis/openlan/pkg/access"
|
"github.com/luscis/openlan/pkg/access"
|
||||||
"github.com/luscis/openlan/pkg/config"
|
"github.com/luscis/openlan/pkg/config"
|
||||||
@@ -12,17 +13,28 @@ import (
|
|||||||
func main() {
|
func main() {
|
||||||
mode := "http"
|
mode := "http"
|
||||||
conf := ""
|
conf := ""
|
||||||
flag.StringVar(&mode, "mode", "http", "Proxy mode for http, socks, tcp and access")
|
flag.StringVar(&mode, "mode", "http", "Proxy mode for http, socks, tcp and name")
|
||||||
flag.StringVar(&conf, "conf", "ceci.yaml", "The configuration file")
|
flag.StringVar(&conf, "conf", "ceci.yaml", "The configuration file")
|
||||||
flag.Parse()
|
flag.Parse()
|
||||||
|
|
||||||
|
if !(mode == "http" || mode == "socks" || mode == "tcp" || mode == "name") {
|
||||||
|
libol.Warn("Ceci: not support mode:%s", mode)
|
||||||
|
os.Exit(1)
|
||||||
|
}
|
||||||
|
|
||||||
libol.PreNotify()
|
libol.PreNotify()
|
||||||
if mode == "http" {
|
|
||||||
c := &config.HttpProxy{Conf: conf}
|
if mode == "name" {
|
||||||
|
c := &config.Point{
|
||||||
|
RequestAddr: true,
|
||||||
|
Terminal: "off",
|
||||||
|
Conf: conf,
|
||||||
|
}
|
||||||
if err := c.Initialize(); err != nil {
|
if err := c.Initialize(); err != nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
p := proxy.NewHttpProxy(c, nil)
|
p := access.NewPoint(c)
|
||||||
|
p.Initialize()
|
||||||
libol.Go(p.Start)
|
libol.Go(p.Start)
|
||||||
} else if mode == "socks" {
|
} else if mode == "socks" {
|
||||||
c := &config.SocksProxy{Conf: conf}
|
c := &config.SocksProxy{Conf: conf}
|
||||||
@@ -38,19 +50,15 @@ func main() {
|
|||||||
}
|
}
|
||||||
p := proxy.NewTcpProxy(c)
|
p := proxy.NewTcpProxy(c)
|
||||||
libol.Go(p.Start)
|
libol.Go(p.Start)
|
||||||
} else if mode == "access" {
|
} else {
|
||||||
c := &config.Point{
|
c := &config.HttpProxy{Conf: conf}
|
||||||
RequestAddr: true,
|
|
||||||
Terminal: "off",
|
|
||||||
Conf: conf,
|
|
||||||
}
|
|
||||||
if err := c.Initialize(); err != nil {
|
if err := c.Initialize(); err != nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
p := access.NewPoint(c)
|
p := proxy.NewHttpProxy(c, nil)
|
||||||
p.Initialize()
|
|
||||||
libol.Go(p.Start)
|
libol.Go(p.Start)
|
||||||
}
|
}
|
||||||
|
|
||||||
libol.SdNotify()
|
libol.SdNotify()
|
||||||
libol.Wait()
|
libol.Wait()
|
||||||
}
|
}
|
||||||
|
2
dist/rootfs/etc/sysconfig/openlan/access.cfg
vendored
2
dist/rootfs/etc/sysconfig/openlan/access.cfg
vendored
@@ -1,4 +1,4 @@
|
|||||||
# --- point.cfg ---
|
# --- point.cfg ---
|
||||||
# This file define the configuration for OpenLAN Point.
|
# This file define the configuration for OpenLAN Point.
|
||||||
|
|
||||||
OPTIONS='-log:file /dev/null -terminal off'
|
OPTIONS='-mode name'
|
||||||
|
@@ -1,4 +1,4 @@
|
|||||||
# --- point.cfg ---
|
# --- point.cfg ---
|
||||||
# This file define the configuration for OpenLAN Proxy.
|
# This file define the configuration for OpenLAN Proxy.
|
||||||
|
|
||||||
OPTIONS='-conf /etc/openlan/proxy.json -log:file /dev/null'
|
OPTIONS='-mode http'
|
@@ -1,11 +1,11 @@
|
|||||||
[Unit]
|
[Unit]
|
||||||
Description=OpenLAN Access daemon for %I
|
Description=Open Access daemon for %I
|
||||||
After=network.target
|
After=network.target
|
||||||
|
|
||||||
[Service]
|
[Service]
|
||||||
Type=notify
|
Type=notify
|
||||||
EnvironmentFile=/etc/sysconfig/openlan/access.cfg
|
EnvironmentFile=/etc/sysconfig/openlan/access.cfg
|
||||||
ExecStart=/usr/bin/openlan-access $OPTIONS -conf /etc/openlan/access/%i.yaml
|
ExecStart=/usr/bin/openceci $OPTIONS -conf /etc/openlan/switch/ceci/%i.yaml
|
||||||
Restart=always
|
Restart=always
|
||||||
|
|
||||||
[Install]
|
[Install]
|
@@ -1,10 +1,11 @@
|
|||||||
[Unit]
|
[Unit]
|
||||||
Description=OpenCeci daemon for %I
|
Description=Open Cecilia daemon for %I
|
||||||
After=network.target
|
After=network.target
|
||||||
|
|
||||||
[Service]
|
[Service]
|
||||||
Type=notify
|
Type=notify
|
||||||
LimitNOFILE=102400
|
LimitNOFILE=102400
|
||||||
|
EnvironmentFile=/etc/sysconfig/openlan/ceci.cfg
|
||||||
ExecStart=/usr/bin/openceci $OPTIONS -conf /etc/openlan/switch/ceci/%i.yaml
|
ExecStart=/usr/bin/openceci $OPTIONS -conf /etc/openlan/switch/ceci/%i.yaml
|
||||||
Restart=always
|
Restart=always
|
||||||
|
|
||||||
|
@@ -453,17 +453,15 @@ func (w *Worker) handleDNS(conn dns.ResponseWriter, r *dns.Msg) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, rr := range resp.Answer {
|
if via != nil && via.Server != "" {
|
||||||
if n, ok := rr.(*dns.A); ok {
|
for _, rr := range resp.Answer {
|
||||||
if via == nil {
|
if n, ok := rr.(*dns.A); ok {
|
||||||
continue
|
name := n.Hdr.Name
|
||||||
}
|
addr := n.A.String()
|
||||||
|
if w.UpdateDNS(name, addr) {
|
||||||
name := n.Hdr.Name
|
w.UpdateRoute(addr, via.Server)
|
||||||
addr := n.A.String()
|
w.listener.Forward(name, addr, via.Server)
|
||||||
if w.UpdateDNS(name, addr) {
|
}
|
||||||
w.UpdateRoute(addr, via.Server)
|
|
||||||
w.listener.Forward(name, addr, via.Server)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user