forked from cristianoliveira/ergo
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feature: Add support to windows setup command
* Add windows setup suport (cristianoliveira#30)
- Loading branch information
1 parent
19a2f77
commit 04e1d08
Showing
5 changed files
with
88 additions
and
3 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
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 @@ | ||
// +build linux darwin | ||
|
||
package commands | ||
|
||
//ShowInternetOptions is just a dummy for now | ||
//this is only used for Windows | ||
func ShowInternetOptions() {} | ||
//InetRefresh is just a dummy. It only has functionality | ||
//in Windows | ||
func InetRefresh() {} |
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,57 @@ | ||
// +build windows | ||
|
||
package commands | ||
|
||
import ( | ||
"fmt" | ||
"log" | ||
"os/exec" | ||
"syscall" | ||
) | ||
|
||
//ShowInternetOptions will display the Internet Options | ||
//control panel. If the user clicks OK here, then the modifications | ||
//will be visible without a restart | ||
//this is just a fallback for the InetRefresh function | ||
func ShowInternetOptions() { | ||
cmd := exec.Command("control", "inetcpl.cpl,Connections,4") | ||
fmt.Println("Starting the Internet Options control panel") | ||
err := cmd.Run() | ||
if err != nil { | ||
log.Printf("Internet Options control panel could not be started.\r\n%s\r\n", err.Error()) | ||
} | ||
} | ||
|
||
//InetRefresh will inform windows that a proxy change was performed. | ||
//if windows is not informed about the change, then the modification will only be noticed | ||
//after a restart | ||
func InetRefresh() { | ||
wininet := syscall.MustLoadDLL("wininet.dll") | ||
inetsetoption := wininet.MustFindProc("InternetSetOptionW") | ||
//Option 39 is INTERNET_OPTION_SETTINGS_CHANGED | ||
ret, _, callErr := inetsetoption.Call(0, 39, 0, 0) | ||
|
||
if ret == 0 { | ||
log.Printf(` | ||
Could not auto refresh the proxy settings. | ||
Step 1 | ||
The received error is: %s | ||
Please press OK on the next dialog.\r\n`, | ||
callErr.Error()) | ||
|
||
ShowInternetOptions() | ||
} | ||
//Option 37 is INTERNET_OPTION_REFRESH | ||
ret, _, callErr = inetsetoption.Call(0, 37, 0, 0) | ||
if ret == 0 { | ||
log.Printf(` | ||
Could not auto refresh the proxy settings. | ||
Step 2 | ||
The received error is: %s | ||
Please press OK on the next dialog.\r\n`, | ||
callErr.Error()) | ||
ShowInternetOptions() | ||
} | ||
|
||
return | ||
} |
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