-
Notifications
You must be signed in to change notification settings - Fork 2
Added isSecure field in the winrm settings. When isSecure is true, we allow HTTPs connection to end point powershell. If isSecure is false, we allow HTTP connection to end point powershell. #5
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from 8 commits
ed045cd
3ee2786
b6d3fb8
e926485
1f5a7ac
a2a6700
7a35eeb
91fe433
cb7a0c3
0df0942
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -27,6 +27,7 @@ const ( | |
| NTLM | ||
| Kerberos | ||
| ) | ||
| const WINRM_HTTP_PORT = 5985 | ||
|
|
||
| // WinRM client used for executing scripts | ||
| // TODO: Add support for NTLM and Kerberos, Only basic is supported for now | ||
|
|
@@ -55,6 +56,8 @@ type winrmSettings struct { | |
| operationTimeout string | ||
| // Timeout of each HTTP call made | ||
| timeout int | ||
| //Whether the call is http or https | ||
|
||
| isSecure bool | ||
| } | ||
|
|
||
| type getEndpointDetails func() endpointDetails | ||
|
|
@@ -108,6 +111,13 @@ func Port(num int) winrmSettingsOption { | |
| } | ||
| } | ||
|
|
||
| func IsSecure(b bool) winrmSettingsOption { | ||
| return func(ws winrmSettings) winrmSettings { | ||
| ws.isSecure = b | ||
| return ws | ||
| } | ||
| } | ||
|
|
||
| func MaxEnvelopeSize(size string) winrmSettingsOption { | ||
| return func(ws winrmSettings) winrmSettings { | ||
| ws.maxEnvelopeSize = size | ||
|
|
@@ -156,6 +166,7 @@ var defaultWinrmSettings winrmSettings = winrmSettings{ | |
| maxEnvelopeSize: "153200", | ||
| locale: "en-US", | ||
| operationTimeout: "PT60.000S", | ||
| isSecure: true, | ||
| } | ||
|
|
||
| // Creates a new WinRM client | ||
|
|
@@ -185,7 +196,11 @@ func NewWinRMClient(details getEndpointDetails, options ...winrmSettingsOption) | |
| for _, o := range options { | ||
| client.winrmSettings = o(client.winrmSettings) | ||
| } | ||
| client.url = fmt.Sprintf("https://%s:%d/wsman", client.ipAddress, client.port) | ||
| if client.isSecure { | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It's a detail but to avoid repeating the whole then use
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. addressed |
||
| client.url = fmt.Sprintf("https://%s:%d/wsman", client.ipAddress, client.port) | ||
| } else { | ||
| client.url = fmt.Sprintf("http://%s:%d/wsman", client.ipAddress, client.port) | ||
| } | ||
| if client.endpointDetails.auth&NTLM == NTLM { | ||
| client.client.Transport = ntlmssp.Negotiator{RoundTripper: client.client.Transport} | ||
| } | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's a detail but this is unused... so I'm wondering why you're adding it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
addressed