0
0
mirror of https://github.com/vx3r/wg-gen-web.git synced 2025-09-11 12:24:27 +00:00

go fmt / badges

This commit is contained in:
vx3r
2020-01-30 16:17:29 +09:00
parent 9b6d610a9c
commit a1828bfcd8
5 changed files with 19 additions and 19 deletions

View File

@ -40,7 +40,7 @@ AllowedIPs = {{.Address}}
{{end}}`
)
// dump client wg config with go template
// DumpClient dump client wg config with go template
func DumpClient(client *model.Client, server *model.Server) (bytes.Buffer, error) {
var tplBuff bytes.Buffer
@ -58,7 +58,7 @@ func DumpClient(client *model.Client, server *model.Server) (bytes.Buffer, error
})
}
// dump server wg config with go template
// DumpServerWg dump server wg config with go template
func DumpServerWg(clients []*model.Client, server *model.Server) (bytes.Buffer, error) {
var tplBuff bytes.Buffer

View File

@ -8,7 +8,7 @@ import (
"strings"
)
// read file content
// ReadFile file content
func ReadFile(path string) (bytes []byte, err error) {
bytes, err = ioutil.ReadFile(path)
if err != nil {
@ -18,7 +18,7 @@ func ReadFile(path string) (bytes []byte, err error) {
return bytes, nil
}
// write content to file
// WriteFile content to file
func WriteFile(path string, bytes []byte) (err error) {
err = ioutil.WriteFile(path, bytes, 0644)
if err != nil {
@ -28,7 +28,7 @@ func WriteFile(path string, bytes []byte) (err error) {
return nil
}
// check if file exists
// FileExists check if file exists
func FileExists(name string) bool {
info, err := os.Stat(name)
if os.IsNotExist(err) {
@ -37,7 +37,7 @@ func FileExists(name string) bool {
return !info.IsDir()
}
// check if directory exists
// DirectoryExists check if directory exists
func DirectoryExists(name string) bool {
info, err := os.Stat(name)
if os.IsNotExist(err) {
@ -46,7 +46,7 @@ func DirectoryExists(name string) bool {
return info.IsDir()
}
// search for an available in cidr against a list of reserved ips
// GetAvailableIp search for an available in cidr against a list of reserved ips
func GetAvailableIp(cidr string, reserved []string) (string, error) {
addresses, err := GetAllAddressesFromCidr(cidr)
if err != nil {
@ -69,7 +69,7 @@ func GetAvailableIp(cidr string, reserved []string) (string, error) {
return "", errors.New("no more available address from cidr")
}
// get all ip addresses from cidr
// GetAllAddressesFromCidr get all ip addresses from cidr
func GetAllAddressesFromCidr(cidr string) ([]string, error) {
ip, ipnet, err := net.ParseCIDR(cidr)
if err != nil {
@ -94,7 +94,7 @@ func inc(ip net.IP) {
}
}
// check if given ip is IPv6
// IsIPv6 check if given ip is IPv6
func IsIPv6(address string) bool {
return strings.Count(address, ":") >= 2
}