mirror of
https://github.com/luscis/openlan.git
synced 2025-09-27 04:46:02 +08:00
fea: rename point to access.
This commit is contained in:
6
Makefile
6
Makefile
@@ -123,7 +123,7 @@ ceci: linux-ceci darwin-ceci windows-ceci ## build all platform ceci
|
||||
|
||||
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-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
|
||||
|
||||
linux-ceci:
|
||||
@@ -148,13 +148,13 @@ linux-bin: linux-gzip ## build linux install binary
|
||||
install: env linux ## install packages
|
||||
@mkdir -p $(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/ca/ca.crt $(LIN_DIR)/var/openlan/cert
|
||||
@cp -rf $(SD)/pkg/public $(LIN_DIR)/var/openlan
|
||||
@mkdir -p $(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
|
||||
@echo "Installed to $(LIN_DIR)"
|
||||
|
||||
|
@@ -48,12 +48,12 @@ func (u Point) List(c *cli.Context) error {
|
||||
|
||||
func (u Point) Commands() *cli.Command {
|
||||
return &cli.Command{
|
||||
Name: "point",
|
||||
Usage: "Point accessed to switch",
|
||||
Name: "access",
|
||||
Usage: "access to this switch",
|
||||
Subcommands: []*cli.Command{
|
||||
{
|
||||
Name: "list",
|
||||
Usage: "Display all points",
|
||||
Usage: "Display all access",
|
||||
Aliases: []string{"ls"},
|
||||
Action: u.List,
|
||||
},
|
12
dist/rootfs/usr/lib/systemd/system/openlan-access@.service
vendored
Executable file
12
dist/rootfs/usr/lib/systemd/system/openlan-access@.service
vendored
Executable 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
|
@@ -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
|
3
dist/rootfs/var/openlan/script/install.sh
vendored
3
dist/rootfs/var/openlan/script/install.sh
vendored
@@ -30,9 +30,12 @@ function requires() {
|
||||
echo "Install dependents ..."
|
||||
## Install packages from repo.
|
||||
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 openvpn dnsmasq bridge-utils ipset procps wget
|
||||
elif [ "$sys"x == "debian"x ]; then
|
||||
apt-get update -y
|
||||
apt install -y net-tools iptables iproute2 tcpdump ca-certificates iperf3
|
||||
apt install -y openvpn dnsmasq bridge-utils ipset procps wget iputils-ping
|
||||
fi
|
||||
|
15
dist/rootfs/var/openlan/script/ovsdb-server.sh
vendored
15
dist/rootfs/var/openlan/script/ovsdb-server.sh
vendored
@@ -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
|
2
dist/rootfs/var/openlan/script/setup.sh
vendored
2
dist/rootfs/var/openlan/script/setup.sh
vendored
@@ -9,7 +9,7 @@ set -x
|
||||
/usr/bin/env modprobe vxlan
|
||||
|
||||
# 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 '*client.ovpn' -delete
|
||||
/usr/bin/env find /var/openlan/openvpn -name '*client.tmpl' -delete
|
||||
|
2
dist/rootfs/var/openlan/script/switch.sh
vendored
2
dist/rootfs/var/openlan/script/switch.sh
vendored
@@ -9,7 +9,7 @@ set -ex
|
||||
sysctl -p /etc/sysctl.d/90-openlan.conf
|
||||
|
||||
# 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 '*client.ovpn' -delete
|
||||
/usr/bin/env find /var/openlan/openvpn -name '*client.tmpl' -delete
|
||||
|
@@ -7,7 +7,6 @@ WORKDIR /root
|
||||
# mirrorlist for centos7 is EOF.
|
||||
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
|
||||
RUN yum update -y && yum install -y epel-release
|
||||
|
||||
ADD ${linux_bin} /tmp
|
||||
RUN DOCKER=yes /tmp/${linux_bin}
|
||||
|
@@ -5,7 +5,6 @@ ARG linux_bin
|
||||
WORKDIR /root
|
||||
|
||||
# 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
|
||||
RUN DOCKER=yes /tmp/${linux_bin}
|
||||
|
@@ -116,13 +116,13 @@ EOF
|
||||
Enable Access Point for central network:
|
||||
|
||||
```
|
||||
systemctl enable --now openlan-point@central
|
||||
systemctl enable --now openlan-access@central
|
||||
```
|
||||
|
||||
Check journal log:
|
||||
|
||||
```
|
||||
journalctl -u openlan-point@central
|
||||
journalctl -u openlan-access@central
|
||||
```
|
||||
|
||||
|
||||
|
@@ -54,17 +54,17 @@ OpenLAN软件包含下面部分:
|
||||
"address": "172.32.10.10/24" ## 一个唯一的子网地址,如共享二层网络填充本地地址
|
||||
},
|
||||
"subnet": { ## 网络的子网配置,如果没有动态地址分配可以忽略
|
||||
"start": "172.32.10.100", ## 用于动态分配给接入point的起始地址
|
||||
"start": "172.32.10.100", ## 用于动态分配给Access Point的起始地址
|
||||
"end": "172.32.10.150", ## 用于动态分配的截止地址
|
||||
"netmask": "255.255.255.0" ## 网络子网的掩码
|
||||
},
|
||||
"hosts": [ ## 为point添加静态地址分配
|
||||
"hosts": [ ## 为Access Point添加静态地址分配
|
||||
{
|
||||
"hostname": "pc-99", ## 接入point的主机名称
|
||||
"hostname": "pc-99", ## Access Point的主机名称
|
||||
"address": "172.32.10.99" ## 固定的地址
|
||||
}
|
||||
],
|
||||
"routes": [ ## 注入给point的路由信息
|
||||
"routes": [ ## 注入给Access Point的路由信息
|
||||
{
|
||||
"prefix": "192.168.10.0/24"
|
||||
}
|
||||
@@ -120,7 +120,7 @@ OpenLAN软件包含下面部分:
|
||||
2. 添加一个新的网络配置;
|
||||
```
|
||||
$ cd /etc/openlan
|
||||
$ cp point.json.example example.json
|
||||
$ cp access.json.example example.json
|
||||
$ vim example.json ## <网络名>.json
|
||||
{
|
||||
"protocol": "tcp", ## 同上
|
||||
@@ -136,8 +136,8 @@ OpenLAN软件包含下面部分:
|
||||
```
|
||||
3. 配置Access Point服务自启动;
|
||||
```
|
||||
$ systemctl enable --now openlan-point@example
|
||||
$ journalctl -u openlan-point@example ## 查看日志信息
|
||||
$ systemctl enable --now openlan-access@example
|
||||
$ journalctl -u openlan-access@example ## 查看日志信息
|
||||
```
|
||||
4. 检测网络是否可达;
|
||||
```
|
||||
|
@@ -11,20 +11,18 @@ import (
|
||||
co "github.com/luscis/openlan/pkg/config"
|
||||
"github.com/luscis/openlan/pkg/libol"
|
||||
"github.com/luscis/openlan/pkg/models"
|
||||
"github.com/luscis/openlan/pkg/schema"
|
||||
nl "github.com/vishvananda/netlink"
|
||||
)
|
||||
|
||||
const (
|
||||
OlapBin = "openlan-point"
|
||||
OlapDir = "/var/openlan/point"
|
||||
AccessBin = "openlan-access"
|
||||
AccessDir = "/var/openlan/access"
|
||||
)
|
||||
|
||||
type Link struct {
|
||||
cfg *co.Point
|
||||
status *schema.Point
|
||||
out *libol.SubLogger
|
||||
uuid string
|
||||
cfg *co.Point
|
||||
out *libol.SubLogger
|
||||
uuid string
|
||||
}
|
||||
|
||||
func NewLink(cfg *co.Point) *Link {
|
||||
@@ -62,23 +60,23 @@ func (l *Link) UUID() string {
|
||||
}
|
||||
|
||||
func (l *Link) Path() string {
|
||||
return OlapBin
|
||||
return AccessBin
|
||||
}
|
||||
|
||||
func (l *Link) ConfFile() string {
|
||||
return filepath.Join(OlapDir, l.uuid+".json")
|
||||
return filepath.Join(AccessDir, l.uuid+".json")
|
||||
}
|
||||
|
||||
func (l *Link) StatusFile() string {
|
||||
return filepath.Join(OlapDir, l.uuid+".status")
|
||||
return filepath.Join(AccessDir, l.uuid+".status")
|
||||
}
|
||||
|
||||
func (l *Link) PidFile() string {
|
||||
return filepath.Join(OlapDir, l.uuid+".pid")
|
||||
return filepath.Join(AccessDir, l.uuid+".pid")
|
||||
}
|
||||
|
||||
func (l *Link) LogFile() string {
|
||||
return filepath.Join(OlapDir, l.uuid+".log")
|
||||
return filepath.Join(AccessDir, l.uuid+".log")
|
||||
}
|
||||
|
||||
func (l *Link) Start() error {
|
||||
|
Reference in New Issue
Block a user