-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #182 from Control-D-Inc/release-branch-v1.3.10
[WIP] Release branch v1.3.10
- Loading branch information
Showing
50 changed files
with
2,107 additions
and
707 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
//go:build !windows | ||
|
||
package cli | ||
|
||
import ( | ||
"github.com/Control-D-Inc/ctrld" | ||
) | ||
|
||
// addExtraSplitDnsRule adds split DNS rule if present. | ||
func addExtraSplitDnsRule(_ *ctrld.Config) {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
package cli | ||
|
||
import ( | ||
"fmt" | ||
"strings" | ||
|
||
"github.com/Control-D-Inc/ctrld" | ||
) | ||
|
||
// addExtraSplitDnsRule adds split DNS rule for domain if it's part of active directory. | ||
func addExtraSplitDnsRule(cfg *ctrld.Config) { | ||
domain, err := getActiveDirectoryDomain() | ||
if err != nil { | ||
mainLog.Load().Debug().Msgf("unable to get active directory domain: %v", err) | ||
return | ||
} | ||
if domain == "" { | ||
mainLog.Load().Debug().Msg("no active directory domain found") | ||
return | ||
} | ||
for n, lc := range cfg.Listener { | ||
if lc.Policy == nil { | ||
lc.Policy = &ctrld.ListenerPolicyConfig{} | ||
} | ||
domainRule := "*." + strings.TrimPrefix(domain, ".") | ||
for _, rule := range lc.Policy.Rules { | ||
if _, ok := rule[domainRule]; ok { | ||
mainLog.Load().Debug().Msgf("domain rule already exist for listener.%s", n) | ||
return | ||
} | ||
} | ||
mainLog.Load().Debug().Msgf("adding active directory domain for listener.%s", n) | ||
lc.Policy.Rules = append(lc.Policy.Rules, ctrld.Rule{domainRule: []string{}}) | ||
} | ||
} | ||
|
||
// getActiveDirectoryDomain returns AD domain name of this computer. | ||
func getActiveDirectoryDomain() (string, error) { | ||
cmd := "$obj = Get-WmiObject Win32_ComputerSystem; if ($obj.PartOfDomain) { $obj.Domain }" | ||
output, err := powershell(cmd) | ||
if err != nil { | ||
return "", fmt.Errorf("failed to get domain name: %w, output:\n\n%s", err, string(output)) | ||
} | ||
return string(output), nil | ||
} |
Oops, something went wrong.