Browse Source

review comments addressed

Signed-off-by: Matthew R. Kasun <[email protected]>
Matthew R. Kasun 3 years ago
parent
commit
adfa5236f8
3 changed files with 8 additions and 7 deletions
  1. 0 1
      compose/docker-compose.contained.yml
  2. 1 0
      netclient/functions/register.go
  3. 7 6
      tls/tls.go

+ 0 - 1
compose/docker-compose.contained.yml

@@ -37,7 +37,6 @@ services:
       MQ_HOST: "mq"
       HOST_NETWORK: "off"
       MANAGE_IPTABLES: "on"
-      PORT_FORWARD_SERVICES: ""
       VERBOSITY: "1"
     ports:
       - "51821-51830:51821-51830/udp"

+ 1 - 0
netclient/functions/register.go

@@ -50,6 +50,7 @@ func Register(cfg *config.ClientConfig, key string) error {
 	return JoinNetwork(cfg, key, false)
 }
 
+// RegisterWithServer calls the register endpoint with privatekey and commonname - api returns ca and client certificate
 func RegisterWithServer(private *ed25519.PrivateKey, cfg *config.ClientConfig) error {
 	data := config.RegisterRequest{
 		Key:        *private,

+ 7 - 6
tls/tls.go

@@ -17,10 +17,11 @@ import (
 	"golang.zx2c4.com/wireguard/wgctrl/wgtypes"
 )
 
-// certificate validity in days
+// CERTTIFICAT_VALIDITY duration of certificate validity in days
 const CERTIFICATE_VALIDITY = 365
 
 type (
+	// Key is the struct for an edwards representation point
 	Key struct {
 		point *edwards25519.Point
 	}
@@ -34,7 +35,7 @@ func NewKey() *Key {
 	return &Key{(&edwards25519.Point{}).ScalarBaseMult(s)}
 }
 
-// Ed25519PrivateKey returns the private key in Edwards form used for EdDSA.
+// Key.Ed25519PrivateKey returns the private key in Edwards form used for EdDSA.
 func (n *Key) Ed25519PrivateKey() (ed25519.PrivateKey, error) {
 	if n.point == nil {
 		return ed25519.PrivateKey{}, errors.New("nil point")
@@ -45,7 +46,7 @@ func (n *Key) Ed25519PrivateKey() (ed25519.PrivateKey, error) {
 	return ed25519.NewKeyFromSeed(n.point.Bytes()), nil
 }
 
-// Curve25519PrivateKey returns the private key in Montogomery form used for ECDH.
+// Key.Curve25519PrivateKey returns the private key in Montogomery form used for ECDH.
 func (n *Key) Curve25519PrivateKey() (wgtypes.Key, error) {
 	if n.point == nil {
 		return wgtypes.Key{}, errors.New("nil point")
@@ -56,7 +57,7 @@ func (n *Key) Curve25519PrivateKey() (wgtypes.Key, error) {
 	return wgtypes.ParseKey(base64.StdEncoding.EncodeToString(n.point.BytesMontgomery()))
 }
 
-// Save : saves the private key to path.
+// Key.Save : saves the private key to path.
 func (n *Key) Save(path string) error {
 	f, err := os.Create(path)
 	if err != nil {
@@ -67,7 +68,7 @@ func (n *Key) Save(path string) error {
 	return nil
 }
 
-// Reads the private key from path.
+// ReadFrom reads a private key from path.
 func ReadFrom(path string) (*Key, error) {
 	key, err := os.ReadFile(path)
 	if err != nil {
@@ -80,7 +81,7 @@ func ReadFrom(path string) (*Key, error) {
 	return &Key{point}, nil
 }
 
-// NewName creates a new pkix.Name
+// NewName creates a new pkix.Name with common name, country, and organization
 func NewName(commonName, country, org string) pkix.Name {
 	res := NewCName(commonName)
 	res.Country = []string{country}