fea: rename point to access.
Some checks are pending
Coverage CI / build (push) Waiting to run
CodeQL / Analyze (go) (push) Waiting to run
Ubuntu CI / build (push) Waiting to run

This commit is contained in:
Daniel Ding
2025-03-21 23:02:50 +08:00
parent 98663ad151
commit 269ed244c0
17 changed files with 42 additions and 58 deletions

View File

@@ -123,7 +123,7 @@ ceci: linux-ceci darwin-ceci windows-ceci ## build all platform ceci
linux: env linux-ceci linux-proxy ## build linux binary linux: env linux-ceci linux-proxy ## build linux binary
go build -mod=vendor -ldflags "$(LDFLAGS)" -o $(BD)/openlan ./cmd/main.go go build -mod=vendor -ldflags "$(LDFLAGS)" -o $(BD)/openlan ./cmd/main.go
go build -mod=vendor -ldflags "$(LDFLAGS)" -o $(BD)/openlan-point ./cmd/point go build -mod=vendor -ldflags "$(LDFLAGS)" -o $(BD)/openlan-access ./cmd/access
go build -mod=vendor -ldflags "$(LDFLAGS)" -o $(BD)/openlan-switch ./cmd/switch go build -mod=vendor -ldflags "$(LDFLAGS)" -o $(BD)/openlan-switch ./cmd/switch
linux-ceci: linux-ceci:
@@ -148,13 +148,13 @@ linux-bin: linux-gzip ## build linux install binary
install: env linux ## install packages install: env linux ## install packages
@mkdir -p $(LIN_DIR) @mkdir -p $(LIN_DIR)
@cp -rf $(SD)/dist/rootfs/{etc,var,usr} $(LIN_DIR) @cp -rf $(SD)/dist/rootfs/{etc,var,usr} $(LIN_DIR)
@mkdir -p $(LIN_DIR)/var/openlan/{cert,openvpn,point,l2tp,dhcp} @mkdir -p $(LIN_DIR)/var/openlan/{cert,openvpn,access,dhcp}
@cp -rf $(SD)/dist/cert/openlan/cert $(LIN_DIR)/var/openlan @cp -rf $(SD)/dist/cert/openlan/cert $(LIN_DIR)/var/openlan
@cp -rf $(SD)/dist/cert/openlan/ca/ca.crt $(LIN_DIR)/var/openlan/cert @cp -rf $(SD)/dist/cert/openlan/ca/ca.crt $(LIN_DIR)/var/openlan/cert
@cp -rf $(SD)/pkg/public $(LIN_DIR)/var/openlan @cp -rf $(SD)/pkg/public $(LIN_DIR)/var/openlan
@mkdir -p $(LIN_DIR)/usr/bin @mkdir -p $(LIN_DIR)/usr/bin
@cp -rf $(BD)/{openlan,openlan-switch} $(LIN_DIR)/usr/bin @cp -rf $(BD)/{openlan,openlan-switch} $(LIN_DIR)/usr/bin
@cp -rf $(BD)/{openlan-point,openlan-proxy} $(LIN_DIR)/usr/bin @cp -rf $(BD)/{openlan-access,openlan-proxy} $(LIN_DIR)/usr/bin
@cp -rf $(BD)/openlan-ceci $(LIN_DIR)/usr/bin @cp -rf $(BD)/openlan-ceci $(LIN_DIR)/usr/bin
@echo "Installed to $(LIN_DIR)" @echo "Installed to $(LIN_DIR)"

View File

@@ -48,12 +48,12 @@ func (u Point) List(c *cli.Context) error {
func (u Point) Commands() *cli.Command { func (u Point) Commands() *cli.Command {
return &cli.Command{ return &cli.Command{
Name: "point", Name: "access",
Usage: "Point accessed to switch", Usage: "access to this switch",
Subcommands: []*cli.Command{ Subcommands: []*cli.Command{
{ {
Name: "list", Name: "list",
Usage: "Display all points", Usage: "Display all access",
Aliases: []string{"ls"}, Aliases: []string{"ls"},
Action: u.List, Action: u.List,
}, },

View File

@@ -0,0 +1,12 @@
[Unit]
Description=OpenLAN Access daemon for %I
After=network.target
[Service]
Type=notify
EnvironmentFile=/etc/sysconfig/openlan/access.cfg
ExecStart=/usr/bin/openlan-access $OPTIONS -conf /etc/openlan/%i.json
Restart=always
[Install]
WantedBy=multi-user.target

View File

@@ -1,12 +0,0 @@
[Unit]
Description=OpenLAN Point daemon for %I
After=network.target
[Service]
Type=notify
EnvironmentFile=/etc/sysconfig/openlan/point.cfg
ExecStart=/usr/bin/openlan-point $OPTIONS -conf /etc/openlan/%i.json
Restart=always
[Install]
WantedBy=multi-user.target

View File

@@ -30,9 +30,12 @@ function requires() {
echo "Install dependents ..." echo "Install dependents ..."
## Install packages from repo. ## Install packages from repo.
if [ "$sys"x == "redhat"x ]; then if [ "$sys"x == "redhat"x ]; then
yum update -y
yum install -y epel-release
yum install -y openssl net-tools iptables iputils iperf3 tcpdump yum install -y openssl net-tools iptables iputils iperf3 tcpdump
yum install -y openvpn dnsmasq bridge-utils ipset procps wget yum install -y openvpn dnsmasq bridge-utils ipset procps wget
elif [ "$sys"x == "debian"x ]; then elif [ "$sys"x == "debian"x ]; then
apt-get update -y
apt install -y net-tools iptables iproute2 tcpdump ca-certificates iperf3 apt install -y net-tools iptables iproute2 tcpdump ca-certificates iperf3
apt install -y openvpn dnsmasq bridge-utils ipset procps wget iputils-ping apt install -y openvpn dnsmasq bridge-utils ipset procps wget iputils-ping
fi fi

View File

@@ -1,15 +0,0 @@
#!/bin/bash
set -ex
if [ ! -f "/etc/openvswitch/conf.db" ]; then
ovsdb-tool create /etc/openvswitch/conf.db
elif ovsdb-tool needs-conversion /etc/openvswitch/conf.db | grep -s -w yes; then
ovsdb-tool convert /etc/openvswitch/conf.db
fi
exec /usr/sbin/ovsdb-server /etc/openvswitch/conf.db \
-vconsole:info -vsyslog:off -vfile:off \
--remote=punix:/run/openvswitch/db.sock \
--remote=db:Open_vSwitch,Open_vSwitch,manager_options \
--pidfile

View File

@@ -9,7 +9,7 @@ set -x
/usr/bin/env modprobe vxlan /usr/bin/env modprobe vxlan
# clean older files. # clean older files.
/usr/bin/env find /var/openlan/point -type f -delete /usr/bin/env find /var/openlan/access -type f -delete
/usr/bin/env find /var/openlan/openvpn -name '*.status' -delete /usr/bin/env find /var/openlan/openvpn -name '*.status' -delete
/usr/bin/env find /var/openlan/openvpn -name '*client.ovpn' -delete /usr/bin/env find /var/openlan/openvpn -name '*client.ovpn' -delete
/usr/bin/env find /var/openlan/openvpn -name '*client.tmpl' -delete /usr/bin/env find /var/openlan/openvpn -name '*client.tmpl' -delete

View File

@@ -9,7 +9,7 @@ set -ex
sysctl -p /etc/sysctl.d/90-openlan.conf sysctl -p /etc/sysctl.d/90-openlan.conf
# clean older files. # clean older files.
/usr/bin/env find /var/openlan/point -type f -delete /usr/bin/env find /var/openlan/access -type f -delete
/usr/bin/env find /var/openlan/openvpn -name '*.status' -delete /usr/bin/env find /var/openlan/openvpn -name '*.status' -delete
/usr/bin/env find /var/openlan/openvpn -name '*client.ovpn' -delete /usr/bin/env find /var/openlan/openvpn -name '*client.ovpn' -delete
/usr/bin/env find /var/openlan/openvpn -name '*client.tmpl' -delete /usr/bin/env find /var/openlan/openvpn -name '*client.tmpl' -delete

View File

@@ -7,7 +7,6 @@ WORKDIR /root
# mirrorlist for centos7 is EOF. # mirrorlist for centos7 is EOF.
RUN sed -i 's/mirrorlist/#mirrorlist/g' /etc/yum.repos.d/*.repo && \ RUN sed -i 's/mirrorlist/#mirrorlist/g' /etc/yum.repos.d/*.repo && \
sed -i 's|#baseurl=http://mirror.centos.org|baseurl=http://vault.centos.org|g' /etc/yum.repos.d/*.repo sed -i 's|#baseurl=http://mirror.centos.org|baseurl=http://vault.centos.org|g' /etc/yum.repos.d/*.repo
RUN yum update -y && yum install -y epel-release
ADD ${linux_bin} /tmp ADD ${linux_bin} /tmp
RUN DOCKER=yes /tmp/${linux_bin} RUN DOCKER=yes /tmp/${linux_bin}

View File

@@ -5,7 +5,6 @@ ARG linux_bin
WORKDIR /root WORKDIR /root
# RUN sed -ie 's/deb.debian.org/mirrors.tuna.tsinghua.edu.cn/g' /etc/apt/sources.list # RUN sed -ie 's/deb.debian.org/mirrors.tuna.tsinghua.edu.cn/g' /etc/apt/sources.list
RUN apt-get update -y
ADD ${linux_bin} /tmp ADD ${linux_bin} /tmp
RUN DOCKER=yes /tmp/${linux_bin} RUN DOCKER=yes /tmp/${linux_bin}

View File

@@ -116,13 +116,13 @@ EOF
Enable Access Point for central network: Enable Access Point for central network:
``` ```
systemctl enable --now openlan-point@central systemctl enable --now openlan-access@central
``` ```
Check journal log: Check journal log:
``` ```
journalctl -u openlan-point@central journalctl -u openlan-access@central
``` ```

View File

@@ -54,17 +54,17 @@ OpenLAN软件包含下面部分
"address": "172.32.10.10/24" ## 一个唯一的子网地址,如共享二层网络填充本地地址 "address": "172.32.10.10/24" ## 一个唯一的子网地址,如共享二层网络填充本地地址
}, },
"subnet": { ## 网络的子网配置,如果没有动态地址分配可以忽略 "subnet": { ## 网络的子网配置,如果没有动态地址分配可以忽略
"start": "172.32.10.100", ## 用于动态分配给接入point的起始地址 "start": "172.32.10.100", ## 用于动态分配给Access Point的起始地址
"end": "172.32.10.150", ## 用于动态分配的截止地址 "end": "172.32.10.150", ## 用于动态分配的截止地址
"netmask": "255.255.255.0" ## 网络子网的掩码 "netmask": "255.255.255.0" ## 网络子网的掩码
}, },
"hosts": [ ## 为point添加静态地址分配 "hosts": [ ## 为Access Point添加静态地址分配
{ {
"hostname": "pc-99", ## 接入point的主机名称 "hostname": "pc-99", ## Access Point的主机名称
"address": "172.32.10.99" ## 固定的地址 "address": "172.32.10.99" ## 固定的地址
} }
], ],
"routes": [ ## 注入给point的路由信息 "routes": [ ## 注入给Access Point的路由信息
{ {
"prefix": "192.168.10.0/24" "prefix": "192.168.10.0/24"
} }
@@ -120,7 +120,7 @@ OpenLAN软件包含下面部分
2. 添加一个新的网络配置; 2. 添加一个新的网络配置;
``` ```
$ cd /etc/openlan $ cd /etc/openlan
$ cp point.json.example example.json $ cp access.json.example example.json
$ vim example.json ## <网络名>.json $ vim example.json ## <网络名>.json
{ {
"protocol": "tcp", ## 同上 "protocol": "tcp", ## 同上
@@ -136,8 +136,8 @@ OpenLAN软件包含下面部分
``` ```
3. 配置Access Point服务自启动 3. 配置Access Point服务自启动
``` ```
$ systemctl enable --now openlan-point@example $ systemctl enable --now openlan-access@example
$ journalctl -u openlan-point@example ## 查看日志信息 $ journalctl -u openlan-access@example ## 查看日志信息
``` ```
4. 检测网络是否可达; 4. 检测网络是否可达;
``` ```

View File

@@ -11,20 +11,18 @@ import (
co "github.com/luscis/openlan/pkg/config" co "github.com/luscis/openlan/pkg/config"
"github.com/luscis/openlan/pkg/libol" "github.com/luscis/openlan/pkg/libol"
"github.com/luscis/openlan/pkg/models" "github.com/luscis/openlan/pkg/models"
"github.com/luscis/openlan/pkg/schema"
nl "github.com/vishvananda/netlink" nl "github.com/vishvananda/netlink"
) )
const ( const (
OlapBin = "openlan-point" AccessBin = "openlan-access"
OlapDir = "/var/openlan/point" AccessDir = "/var/openlan/access"
) )
type Link struct { type Link struct {
cfg *co.Point cfg *co.Point
status *schema.Point out *libol.SubLogger
out *libol.SubLogger uuid string
uuid string
} }
func NewLink(cfg *co.Point) *Link { func NewLink(cfg *co.Point) *Link {
@@ -62,23 +60,23 @@ func (l *Link) UUID() string {
} }
func (l *Link) Path() string { func (l *Link) Path() string {
return OlapBin return AccessBin
} }
func (l *Link) ConfFile() string { func (l *Link) ConfFile() string {
return filepath.Join(OlapDir, l.uuid+".json") return filepath.Join(AccessDir, l.uuid+".json")
} }
func (l *Link) StatusFile() string { func (l *Link) StatusFile() string {
return filepath.Join(OlapDir, l.uuid+".status") return filepath.Join(AccessDir, l.uuid+".status")
} }
func (l *Link) PidFile() string { func (l *Link) PidFile() string {
return filepath.Join(OlapDir, l.uuid+".pid") return filepath.Join(AccessDir, l.uuid+".pid")
} }
func (l *Link) LogFile() string { func (l *Link) LogFile() string {
return filepath.Join(OlapDir, l.uuid+".log") return filepath.Join(AccessDir, l.uuid+".log")
} }
func (l *Link) Start() error { func (l *Link) Start() error {