Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions cmd/join.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,8 @@ func init() {
joinCmd.Flags().StringP(registerFlags.Name, "o", "", "sets host name")
joinCmd.Flags().StringP(registerFlags.Interface, "I", "", "sets netmaker interface to use on host")
joinCmd.Flags().StringP(registerFlags.Firewall, "f", "", "selects firewall to use on host: iptables/nftables")
joinCmd.Flags().BoolP(registerFlags.ForcePrivate, "P", false, "forces Windows network interface to be classified as Private")
joinCmd.Flags().StringP(registerFlags.ProfileName, "N", "", "sets Windows network profile name for the interface")
rootCmd.AddCommand(joinCmd)
}

Expand Down
74 changes: 47 additions & 27 deletions cmd/register.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,34 +21,38 @@ import (
)

var registerFlags = struct {
Firewall string
Server string
User string
Token string
Network string
AllNetworks string
EndpointIP string
EndpointIP6 string
Port string
MTU string
StaticPort string
Static string
Interface string
Name string
Firewall string
Server string
User string
Token string
Network string
AllNetworks string
EndpointIP string
EndpointIP6 string
Port string
MTU string
StaticPort string
Static string
Interface string
Name string
ForcePrivate string
ProfileName string
}{
Server: "server",
User: "user",
Token: "token",
Network: "net",
AllNetworks: "all-networks",
EndpointIP: "endpoint-ip",
Port: "port",
MTU: "mtu",
StaticPort: "static-port",
Static: "static-endpoint",
Name: "name",
Interface: "interface",
Firewall: "firewall",
Server: "server",
User: "user",
Token: "token",
Network: "net",
AllNetworks: "all-networks",
EndpointIP: "endpoint-ip",
Port: "port",
MTU: "mtu",
StaticPort: "static-port",
Static: "static-endpoint",
Name: "name",
Interface: "interface",
Firewall: "firewall",
ForcePrivate: "force-private",
ProfileName: "profile-name",
}

// registerCmd represents the register command
Expand Down Expand Up @@ -147,6 +151,22 @@ func setHostFields(cmd *cobra.Command) {
config.Netclient().FirewallInUse = firewall
}
}
if forcePrivate, err := cmd.Flags().GetBool(registerFlags.ForcePrivate); err == nil {
if ncutils.IsWindows() {
config.Netclient().ForcePrivateProfile = forcePrivate
}
}
if profileName, err := cmd.Flags().GetString(registerFlags.ProfileName); err == nil && profileName != "" {
if ncutils.IsWindows() {
config.Netclient().InterfaceProfileName = profileName
}
}
// Save config if any Windows-specific settings were changed
if ncutils.IsWindows() && (cmd.Flags().Changed(registerFlags.ForcePrivate) || cmd.Flags().Changed(registerFlags.ProfileName)) {
if err := config.WriteNetclientConfig(); err != nil {
logger.Log(0, "failed to save config after setting Windows interface settings", err.Error())
}
}
}
func validateIface(iface string) bool {
if iface == "" {
Expand Down
4 changes: 4 additions & 0 deletions config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,10 @@ type Config struct {
NameServers []string `json:"name_servers" yaml:"name_servers"`
DNSSearch string `json:"dns_search" yaml:"dns_search"`
DNSOptions string `json:"dns_options" yaml:"dns_options"`
// ForcePrivateProfile - force Windows network interface to be classified as Private
ForcePrivateProfile bool `json:"force_private_profile" yaml:"force_private_profile"`
// InterfaceProfileName - Windows network profile name for the interface
InterfaceProfileName string `json:"interface_profile_name" yaml:"interface_profile_name"`
}

func init() {
Expand Down
Loading