mirror of
https://github.com/amnezia-vpn/amneziawg-go.git
synced 2025-07-31 00:52:51 +02:00
delete remains of old cfg gen
Signed-off-by: Mark Puha <marko10@inf.elte.hu>
This commit is contained in:
parent
6c2c04ebd4
commit
392767a203
4 changed files with 0 additions and 128 deletions
12
README.md
12
README.md
|
@ -51,18 +51,6 @@ This requires an installation of the latest version of [Go](https://go.dev/).
|
|||
```
|
||||
$ git clone https://git.zx2c4.com/wireguard-go
|
||||
$ cd wireguard-go
|
||||
```
|
||||
|
||||
### Config gen
|
||||
The configs are generate from a yml file. If you want to change the config run `make cfg_gen config_name` where `config_name` is the name of the yaml file you'd like to generate from. The script will search in the `cfg/settings/` folder
|
||||
|
||||
### Example:
|
||||
`make cfg_gen default` will generate a config from `cfg/settings/default.yml` the file will be called `cfg/cfg_values.go`
|
||||
|
||||
Every time you make changes to the yml you need to rerun.
|
||||
|
||||
After the generation is done you can build with:
|
||||
```
|
||||
$ make
|
||||
```
|
||||
|
||||
|
|
|
@ -1,15 +0,0 @@
|
|||
// THIS IS A GENERATED FILE; ANY MODIFICATION WILL BE LOST
|
||||
|
||||
package cfg
|
||||
|
||||
const JunkPacketCount int = {{.JunkPacketCount}}
|
||||
const JunkPacketMinSize int = {{.JunkPacketMinSize}}
|
||||
const JunkPacketMaxSize int = {{.JunkPacketMaxSize}}
|
||||
const InitPacketJunkSize int = {{.InitPacketJunkSize}}
|
||||
const ResponsePacketJunkSize int = {{.ResponsePacketJunkSize}}
|
||||
const UnderLoadPacketJunkSize int = {{.UnderLoadPacketJunkSize}}
|
||||
const TransportPacketJunkSize int = {{.TransportPacketJunkSize}}
|
||||
const InitPacketMagicHeader uint32 = {{.InitPacketMagicHeader}}
|
||||
const ResponsePacketMagicHeader uint32 = {{.ResponsePacketMagicHeader}}
|
||||
const UnderloadPacketMagicHeader uint32 = {{.UnderloadPacketMagicHeader}}
|
||||
const TransportPacketMagicHeader uint32 = {{.TransportPacketMagicHeader}}
|
|
@ -1,43 +0,0 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"html/template"
|
||||
"os"
|
||||
"path/filepath"
|
||||
|
||||
"golang.zx2c4.com/wireguard/util/cfgGenerator/internal/config"
|
||||
)
|
||||
|
||||
func main() {
|
||||
cfgName := "default"
|
||||
if len(os.Args) != 1 {
|
||||
cfgName = os.Args[1]
|
||||
} else {
|
||||
fmt.Println("WARNING; config name omited; using default")
|
||||
}
|
||||
|
||||
ex, err := os.Executable()
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
mainPath := filepath.Dir(ex)
|
||||
cfgPath := mainPath + "/cfg/"
|
||||
cfgFilePath := cfgPath + "settings/" + cfgName + ".yml"
|
||||
|
||||
cfgTmpl, err := template.ParseFiles(
|
||||
mainPath + "/util/cfgGenerator/cfg_values.txt",
|
||||
)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
cfg, err := config.NewFromFilename(cfgFilePath)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
f, _ := os.Create(cfgPath + "cfg_values.go")
|
||||
|
||||
defer f.Close()
|
||||
cfgTmpl.Execute(f, *cfg)
|
||||
f.Sync()
|
||||
}
|
|
@ -1,58 +0,0 @@
|
|||
package config
|
||||
|
||||
import (
|
||||
"io/ioutil"
|
||||
|
||||
"github.com/juju/errors"
|
||||
"gopkg.in/yaml.v3"
|
||||
)
|
||||
|
||||
type config struct {
|
||||
JunkPacketCount int `yaml:"junk_packet_count"`
|
||||
JunkPacketMinSize int `yaml:"junk_packet_min_size"`
|
||||
JunkPacketMaxSize int `yaml:"junk_packet_max_size"`
|
||||
InitPacketJunkSize int `yaml:"init_packet_junk_size"`
|
||||
ResponsePacketJunkSize int `yaml:"response_packet_junk_size"`
|
||||
UnderLoadPacketJunkSize int `yaml:"underload_packet_junk_size"`
|
||||
TransportPacketJunkSize int `yaml:"transport_packet_junk_size"`
|
||||
InitPacketMagicHeader uint32 `yaml:"init_packet_magic_header"`
|
||||
ResponsePacketMagicHeader uint32 `yaml:"response_packet_magic_header"`
|
||||
UnderloadPacketMagicHeader uint32 `yaml:"underload_packet_magic_header"`
|
||||
TransportPacketMagicHeader uint32 `yaml:"transport_packet_magic_header"`
|
||||
}
|
||||
|
||||
// New creates a new CW from a file by the given name
|
||||
func New(name string) (*config, error) {
|
||||
return NewFromFilename(name)
|
||||
}
|
||||
|
||||
// NewFromFilename creates a new CW from a file by the given filename
|
||||
func NewFromFilename(filename string) (*config, error) {
|
||||
data, err := ioutil.ReadFile(filename)
|
||||
if err != nil {
|
||||
return nil, errors.Trace(err)
|
||||
}
|
||||
|
||||
return NewFromRaw(data)
|
||||
}
|
||||
|
||||
// NewFromRaw creates a new CW by unmarshaling the given raw data
|
||||
func NewFromRaw(raw []byte) (*config, error) {
|
||||
cfg := &config{}
|
||||
if err := yaml.Unmarshal(raw, cfg); err != nil {
|
||||
return nil, errors.Trace(err)
|
||||
}
|
||||
|
||||
return cfg, nil
|
||||
}
|
||||
|
||||
// TODO
|
||||
// String can't be defined on a value receiver here because of the mutex
|
||||
func (c *config) String() string {
|
||||
raw, err := yaml.Marshal(c)
|
||||
if err != nil {
|
||||
return err.Error()
|
||||
}
|
||||
|
||||
return string(raw)
|
||||
}
|
Loading…
Add table
Reference in a new issue