Skip to content

Commit

Permalink
Infrastructure working
Browse files Browse the repository at this point in the history
Signed-off-by: Rasmi V. Mahmoud <[email protected]>
  • Loading branch information
rasmim committed Jul 6, 2022
1 parent bfd7e8b commit 81df451
Show file tree
Hide file tree
Showing 12 changed files with 852 additions and 872 deletions.
80 changes: 38 additions & 42 deletions config/config.go
Original file line number Diff line number Diff line change
@@ -1,22 +1,18 @@
package config

import (
"errors"
"fmt"
"github.com/alecthomas/gometalinter/_linters/src/gopkg.in/yaml.v2"
"io/ioutil"
"os/user"
"path/filepath"

"github.com/aau-network-security/sandbox/virtual/docker"
"github.com/alecthomas/gometalinter/_linters/src/gopkg.in/yaml.v2"
dockerclient "github.com/fsouza/go-dockerclient"
"github.com/rs/zerolog/log"
"io/ioutil"
)

type Config struct {
VmConfig VmConfig `yaml:"vm-config"`
WireguardService WgConnConf `yaml:"wireguard-service"`
DefatConfig DefattConf `yaml:"defat-config"`
VmConfig VmConfig `yaml:"vm-config"`
//WireguardService WgConnConf `yaml:"wireguard-service"`
//DefatConfig DefattConf `yaml:"defat-config"`
DockerRepositories []dockerclient.AuthConfiguration `yaml:"docker-repositories"`
}

Expand All @@ -25,30 +21,30 @@ type VmConfig struct {
//OvaDir string `yaml:"ova-test"` //use for local test
}

type DefattConf struct {
Endpoint string `yaml:"endpoint"`
Port uint64 `yaml:"port"`
SigningKey string `yaml:"sign-key"`
UsersFile string `yaml:"users-file"`
CertConf CertificateConfig `yaml:"tls"`
}
//type DefattConf struct {
// Endpoint string `yaml:"endpoint"`
// Port uint64 `yaml:"port"`
// SigningKey string `yaml:"sign-key"`
// UsersFile string `yaml:"users-file"`
// CertConf CertificateConfig `yaml:"tls"`
//}

type WgConnConf struct {
Endpoint string `yaml:"endpoint"`
Port uint64 `yaml:"port"`
AuthKey string `yaml:"auth-key"`
SignKey string `yaml:"sign-key"`
Dir string `yaml:"client-conf-dir"`
CertConf CertificateConfig `yaml:"tls"`
}

type CertificateConfig struct {
Enabled bool `yaml:"enabled"`
Directory string `yaml:"directory"`
CertFile string `yaml:"certfile"`
CertKey string `yaml:"certkey"`
CAFile string `yaml:"cafile"`
}
//type WgConnConf struct {
// Endpoint string `yaml:"endpoint"`
// Port uint64 `yaml:"port"`
// AuthKey string `yaml:"auth-key"`
// SignKey string `yaml:"sign-key"`
// Dir string `yaml:"client-conf-dir"`
// CertConf CertificateConfig `yaml:"tls"`
//}
//
//type CertificateConfig struct {
// Enabled bool `yaml:"enabled"`
// Directory string `yaml:"directory"`
// CertFile string `yaml:"certfile"`
// CertKey string `yaml:"certkey"`
// CAFile string `yaml:"cafile"`
//}

func NewConfig(path string) (*Config, error) {
f, err := ioutil.ReadFile(path)
Expand All @@ -70,16 +66,16 @@ func NewConfig(path string) (*Config, error) {
if c.VmConfig.OvaDir == "" {
return nil, fmt.Errorf("Specify vm directory, err: %v", err)
}

if c.WireguardService.CertConf.Enabled {
if c.WireguardService.CertConf.Directory == "" {
usr, err := user.Current()
if err != nil {
return nil, errors.New("Invalid user")
}
c.WireguardService.CertConf.Directory = filepath.Join(usr.HomeDir, ".local", "share", "certmagic")
}
}
//
//if c.WireguardService.CertConf.Enabled {
// if c.WireguardService.CertConf.Directory == "" {
// usr, err := user.Current()
// if err != nil {
// return nil, errors.New("Invalid user")
// }
// c.WireguardService.CertConf.Directory = filepath.Join(usr.HomeDir, ".local", "share", "certmagic")
// }
//}

return &c, nil
}
44 changes: 22 additions & 22 deletions config/config.yml
Original file line number Diff line number Diff line change
@@ -1,28 +1,28 @@
vm-config:
ova-dir: /home/vlad/frondends
ova-dir: /home/vlad/front
# ova-test: /Users/rvm/Downloads/AAUJOB/NAP/2021/defatt/virtual/vbox/
wireguard-service:
endpoint: localhost
port: 5353
auth-key: deneme
sign-key: test
client-conf-dir: /etc/wireguard/
tls:
enabled: false
certfile: <absolute-path-to-wg-certFile>
certkey: <absolute-path-to-wg-certKey>
cafile: <absolute-path-to-wg-caFile>
#wireguard-service:
# endpoint: localhost
# port: 5353
# auth-key: deneme
# sign-key: test
# client-conf-dir: /etc/wireguard/
# tls:
# enabled: false
# certfile: <absolute-path-to-wg-certFile>
# certkey: <absolute-path-to-wg-certKey>
# cafile: <absolute-path-to-wg-caFile>

defat-config:
endpoint: localhost
port: 5454
tls:
enabled: false
certFile:
certKey:
caFile:
sign-key:
users-file: /Users/rvm/Downloads/AAUJOB/NAP/2021/defatt/config/users.yml
#defat-config:
# endpoint: localhost
# port: 5454
# tls:
# enabled: false
# certFile:
# certKey:
# caFile:
# sign-key:
# users-file: /Users/rvm/Downloads/AAUJOB/NAP/2021/defatt/config/users.yml

docker-repositories:
- username: hknd
Expand Down
Loading

0 comments on commit 81df451

Please sign in to comment.