diff --git a/dist/resource/point.cfg b/dist/resource/point.cfg index b13d588..48904d6 100755 --- a/dist/resource/point.cfg +++ b/dist/resource/point.cfg @@ -1,4 +1,4 @@ # --- point.cfg --- # This file define the configuration for OpenLAN Point. -OPTIONS='-log:file /dev/null -terminal off -cacert /etc/openlan/ca-trusted.crt' +OPTIONS='-log:file /dev/null -terminal off' diff --git a/dist/script/install.sh b/dist/script/install.sh index fed2e08..c9476f8 100755 --- a/dist/script/install.sh +++ b/dist/script/install.sh @@ -12,11 +12,12 @@ function download() { } function requires() { - local os=$(cat /etc/os-release | grep ^ID= | sed 's/"//g') - if echo $os | grep -q -e centos -e redhat; then - yum install -y net-tools iptables iputils openvpn openssl11 openvswitch dnsmasq - elif echo $os | grep -q -e debian -e ubuntu; then - apt-get install -y net-tools iptables iproute2 openvpn openssl openvswitch-switch dnsmasq + if type yum > /dev/null; then + yum install -y net-tools iptables iputils openvpn openvswitch dnsmasq + elif type apt > /dev/null; then + apt-get install -y net-tools iptables iproute2 openvpn openvswitch-switch dnsmasq + else + echo "We didn't find yum and apt." fi } diff --git a/pkg/cache/store_test.go b/pkg/cache/store_test.go index 94443f0..f6d60c1 100644 --- a/pkg/cache/store_test.go +++ b/pkg/cache/store_test.go @@ -24,35 +24,35 @@ func TestInit(t *testing.T) { Init(cfg) fmt.Println(Point) Point.Add(&models.Point{ - UUID: "fake", + UUID: "fake", Client: &SocketClientMock{}, }) - assert.Equal(t, 1 , Point.Clients.Len(), "MUST be same") + assert.Equal(t, 1, Point.Clients.Len(), "MUST be same") EspState.Add(&models.EspState{ - EspState: &schema.EspState {}, + EspState: &schema.EspState{}, }) - assert.Equal(t, 1 , EspState.State.Len(), "MUST be same") + assert.Equal(t, 1, EspState.State.Len(), "MUST be same") User.Add(&models.User{ - Alias: "fake", + Alias: "fake", }) - assert.Equal(t, 1 , User.Users.Len(), "MUST be same") + assert.Equal(t, 1, User.Users.Len(), "MUST be same") Link.Add("fake-uuid", &models.Link{ - User: "fake", + User: "fake", }) - assert.Equal(t, 1 , Link.Links.Len(), "MUST be same") + assert.Equal(t, 1, Link.Links.Len(), "MUST be same") EspPolicy.Add(&models.EspPolicy{ EspPolicy: &schema.EspPolicy{}, }) - assert.Equal(t, 1 , EspPolicy.Policy.Len(), "MUST be same") + assert.Equal(t, 1, EspPolicy.Policy.Len(), "MUST be same") Online.Add(&models.Line{ - EthType: 0, + EthType: 0, }) - assert.Equal(t, 1 , Online.Lines.Len(), "MUST be same") + assert.Equal(t, 1, Online.Lines.Len(), "MUST be same") Neighbor.Add(&models.Neighbor{ Network: "fake", }) - assert.Equal(t, 1 , Neighbor.Neighbors.Len(), "MUST be same") + assert.Equal(t, 1, Neighbor.Neighbors.Len(), "MUST be same") Reload() assert.Equal(t, 0, EspState.State.Len(), "MUST be same") - assert.Equal(t, 0 , EspPolicy.Policy.Len(), "MUST be same") -} \ No newline at end of file + assert.Equal(t, 0, EspPolicy.Policy.Len(), "MUST be same") +} diff --git a/pkg/config/esp_test.go b/pkg/config/esp_test.go index 17caebd..efac57f 100644 --- a/pkg/config/esp_test.go +++ b/pkg/config/esp_test.go @@ -10,15 +10,15 @@ func TestESPSpecifies(t *testing.T) { State: EspState{ Local: "3.3.3.1", Crypt: "fake-crypt", - Auth: "fake-auth", + Auth: "fake-auth", }, Members: []*ESPMember{ { - Peer: "1.1.1.0", + Peer: "1.1.1.0", Address: "1.1.1.1", Spi: 0x01, - State:EspState{ - Remote: "3.3.3.3", + State: EspState{ + Remote: "3.3.3.3", }, }, }, @@ -34,30 +34,30 @@ func TestESPSpecifies_GetMember(t *testing.T) { State: EspState{ Local: "3.3.3.1", Crypt: "fake-crypt", - Auth: "fake-auth", + Auth: "fake-auth", }, Members: []*ESPMember{ { - Peer: "1.1.1.0", + Peer: "1.1.1.0", Address: "1.1.1.1", Spi: 123, - State:EspState{ - Remote: "3.3.3.3", + State: EspState{ + Remote: "3.3.3.3", }, }, }, } spec.Correct() obj := spec.GetMember("spi:123") - assert.Equal(t, spec.Members[0], obj, "be the same.") + assert.Equal(t, spec.Members[0], obj, "be the same.") // Add { mem1 := &ESPMember{ - Peer: "1.1.1.0", + Peer: "1.1.1.0", Address: "1.1.1.2", Spi: 124, - State:EspState{ - Remote: "3.3.3.4", + State: EspState{ + Remote: "3.3.3.4", }, } spec.AddMember(mem1) @@ -79,12 +79,12 @@ func TestESPSpecifies_GetMember(t *testing.T) { func TestESPSpecifies_AddPolicy(t *testing.T) { mem := &ESPMember{ - Peer: "1.1.1.0", + Peer: "1.1.1.0", Address: "1.1.1.2", Spi: 124, - State:EspState{ - Local: "3.3.3.1", - Remote: "3.3.3.3", + State: EspState{ + Local: "3.3.3.1", + Remote: "3.3.3.3", }, } mem.Correct() @@ -98,4 +98,4 @@ func TestESPSpecifies_AddPolicy(t *testing.T) { mem.RemovePolicy(po.Dest) assert.Equal(t, 1, len(mem.Policies), "be the same.") } -} \ No newline at end of file +} diff --git a/pkg/config/proxy_test.go b/pkg/config/proxy_test.go index 181dd4c..90c4aa6 100644 --- a/pkg/config/proxy_test.go +++ b/pkg/config/proxy_test.go @@ -6,23 +6,23 @@ import ( func TestNewProxy(t *testing.T) { obj := &Proxy{ - Http: []*HttpProxy{ - { - Listen: "0.0.0.0:80", - Cert: &Cert{ - Dir: "/var/run", + Http: []*HttpProxy{ + { + Listen: "0.0.0.0:80", + Cert: &Cert{ + Dir: "/var/run", + }, }, }, - }, - Tcp: []*TcpProxy{ - { - Listen:"0.0.0.0:22", - Target: []string{ - "1.1.1.1:23", - "1.1.1.2:34", + Tcp: []*TcpProxy{ + { + Listen: "0.0.0.0:22", + Target: []string{ + "1.1.1.1:23", + "1.1.1.2:34", + }, }, }, - }, } obj.Correct() -} \ No newline at end of file +} diff --git a/pkg/switch/switch_test.go b/pkg/switch/switch_test.go index 06e55d8..9f81af2 100755 --- a/pkg/switch/switch_test.go +++ b/pkg/switch/switch_test.go @@ -9,8 +9,10 @@ import ( func TestSwitch_LoadPass(t *testing.T) { sw := &Switch{} - sw.LoadPass("../../.password.no") - sw.LoadPass("../../packaging/resource/password.example") + cache.User.SetFile("../../.password.no") + sw.LoadPass() + cache.User.SetFile("../../packaging/resource/password.example") + sw.LoadPass() for user := range cache.User.List() { if user == nil { break