Redirect 'go get' to use SOCKS [duplicate] - go

I want to run go install to install the tour, but I can't find the option to use a proxy for internet access. I don't need this just for the tour but for developing in Go in general.
How do I configure Go to use a proxy.

Go programs understand environment variables http_proxy and no_proxy, but that's not enough because go get uses source control managers for retrieving code. So you have to set HTTP proxy settings for your SCM too. Use this for Mercurial and this for Git.
http_proxy value can be like http://user:password#host:port/. User, password, and port parts are optional. no_proxy is a comma-separated list of servers that should not be connected through proxy. Its value can be like foo.com,bar.net:4000.
You can set these environment variables in your bash_profile, but if you want to limit their usage to go, you can run it like this:
$ http_proxy=127.0.0.1:8080 go get code.google.com/p/go.crypto/bcrypt
If that's what you always want, set this alias to avoid typing proxy part every time:
$ alias go='http_proxy=127.0.0.1:8080 go'
From now on you can use go normally, but it uses your HTTP proxy.

On Windows command line:
set http_proxy=http://[user]:[pass]#[proxy_ip]:[proxy_port]/
set https_proxy=http://[user]:[pass]#[proxy_ip]:[proxy_port]/
...then navigate to https://github.com/ and download the GitHub certificate (I set the name as goland_cert.cer)
...now execute the OpenSSL command to export this to PEM format
openssl x509 -inform der -in goland_cert.cer -out goland_cert.pem
...finally set the certificate in git global config
git config --global http.sslCAInfo C:/Users/[User]/certs/golang_cert.pem

This works for me:
alias go='http_proxy=http://127.0.0.1:1081/ https_proxy=http://127.0.0.1:1081/ no_proxy=localhost,127.0.0.0/8,::1 go'
Note: for someones, protocol may be different https_proxy=http://127.0.0.1:1081

you can also map http requests to socks5 traffic by using https://github.com/cyfdecyf/cow/
very handy if you are blocked by GFW

Add GOPROXY variable name and Variable value as your proxy in the System variable. This worked for me.

You may want check https://github.com/hmgle/graftcp,
$ graftcp-local/graftcp-local -h
Usage of graftcp-local/graftcp-local:
-config string
Path to the configuration file
-listen string
Listen address (default ":2233")
-logfile string
Write logs to file
-loglevel value
Log level (0-6) (default 1)
-pipepath string
Pipe path for graftcp to send address info (default "/tmp/graftcplocal.fifo")
-service string
Control the system service: ["start" "stop" "restart" "install" "uninstall"]
-socks5 string
SOCKS5 address (default "127.0.0.1:1080")
-syslog
Send logs to the local system logger (Eventlog on Windows, syslog on Unix)
If you already have shadowsocks listening on 1080, then you don't need provide any paramaters, just run graftcp-local, to proxy go get
$ ./graftcp go get -v golang.org/x/net/proxy

I solved this problem with the Go command setting some variables in the Win10 system.
Here ("Using the cf CLI with a Proxy Server") you can find the information described below, with images. Also you can read information about:
Format of https_proxy
Use SOCKS5 with cf v3-ssh
Set https_proxy in Mac OS or Linux
I included in this answer only information about W10 because is the one I tested.
Windows 10
Set the new path variable.
From the search box, type in path
Select and open "Edit the system environment variables (control panel)".
"System properties" window will open.
Select "Advanced" tab.
Press "Environment Variables" button, a window with the same name will open.
In "System Variables" section, press the "New" button. "New System Variable" window will open.
You'll now add the needed variable, fill the fields as follows:
Variable name: https_proxy
Variable value:http://yourUserName:userNamePassword#yourIPaddress:port
Lastly...
I tested the installation command line for go.
Open the console, and type in: go install github.com/isacikgoz/gitbatch/cmd/gitbatch#latest
That's an example from this project: https://github.com/isacikgoz/gitbatch
This worked on my particular W10 19043 system.

git config [--global] http.proxy http://proxy.example.com:port
git config [--global] https.proxy http://proxy.example.com:port
see https://github.com/golang/go/wiki/GoGetProxyConfig

Related

Remote debuging with gdbserver for application with X (qt) environment

I have been trying to remotely debug an application which can only be run on a specific server because of hardware limitations. To normally run the program I would login to an ssh shell with X.11 forwarding enabled (-X option of ssh) and its QT interface will show up.
I have been trying to achieve the same but with no success while debugging via gdb with the gdbserver and the integrated gdb client of Eclipse IDE.
Is there a way to achieve this?
I have already tried to copy the settings of the system variables DISPLAY and XDG_RUNTIME_DIR of an ssh -X session (the later being empty) but with no success. Searching for it gives no relatable results (or I may need a hint on what to search).
It's not the cleanest solution, but you can manually set the DISPLAY variable in /etc/environment. Variables set in /etc/environment are available to the entire system. You'll need to reboot the server before gdb will see it.
See: https://help.ubuntu.com/community/EnvironmentVariables#A.2Fetc.2Fenvironment
Here's a one-liner to append your current DISPLAY variable
echo "DISPLAY=$DISPLAY" >> /etc/environment

Configure proxy settings in Notepad++ via Plugin Manager

I would like to configure proxy settings in Notepad++ to allow downloads from the internet via a proxy. After searching how to do that from the net I understand that I need to do that in the Plugin Manager, via the Settings button. When I go to Plugins>Plugin Manager>Show Plugin Manager>Settings I get the dialog box below which does not give me any option for indicating the proxy settings. How do I get to the point that I need to indicate the proxy settings?
Open cmd and type:
cd /d C:\Program Files (x86)\Notepad++\updater
gup -options
A dialog comes up to set the proxy settings.
with version 7.6.6 (april 2019) (probably onwards), you can run notepad++ as admin, use menu '?' > Set Updater Proxy... close notepad++ and open it again as standard user.
From the command line we have to access to the \updater folder of Notepad ++
> cd /d C:\Program Files (x86)\Notepad++\updater
then :
> gup -options
The window for proxy configuration is displayed:
for 32 bit installation
create a file caleld gpupOptions.xml under updater folder where gpup.exe is present
file content
<GUPOptions>
<Proxy>
<server>proxy.com</server>
<port>8080</port>
</Proxy>
</GUPOptions>
If you want to set proxy for Plugin Manager, maybe you need to check this config file:
%AppData%\Notepad++\plugins\config\PluginManager.ini
There are proxy address and proxy port settings.
But in my personal experience, it's not working. Not sure what goes wrong.
I'm on Plugin Manager 1.4.9.0 with Notepad++ v7.5.6 (32-bit)

PHPStorm unable to connect to svn+ssh repository on windows

I'm attempting to use PHPStorm's built-in VCS functionality on a windows machine. When I set it up to utilize svn+ssh, I get the following error:
Problems while loading file history: svn: E170012: Unable to connect to a repository at URL 'svn+ssh://user#svr/repo_path/trunk'
svn: E170012: Can't create tunnel
svn: E720087: Can't create tunnel: The parameter is incorrect.
The repository information is correct and I don't have any issues connecting via TortoiseSVN. I've attempted to configure it utilizing both TortoisePlink.exe and putty's plink.exe. I've used both Pageant and tried to provide the key at the command line.
I normally work with OS X and Linux environments, but that's not an option in this case and I'm not exactly sure what to check next and I'm not finding a lot online via google search. Any suggestions would be greatly appreciated.
I ran into the same issue and found this path to the solution: How to use svn+ssh with Tortoise SVN from the command line
In context of PhpStorm:
PhpStorm discontinued using SVNKit with svn >= 1.8 so it will not ask for your SSH credentials anymore as it did before but will depend on proper command-line clients to be available and configured.
Now, this works for me:
Load your private key with Putty pageant (double click on key and enter your password)
Add a SVN_SSH Windows environment variable with content: C:\\Program Files\\TortoiseSVN\\bin\\TortoisePlink.exe (Adjust to your path, but keep the double backslashes!)
Now, from the command line (restart command line window before trying)
echo %SVN_SSH% needs to give you the plink.exe path and you should be able to do a svn up on command line without entering your password.
Restart your PhpStorm and SVN should work.
I've spent quite time on the issue, yet still couldn't find the exact problem. One issue is about the 1.8 format of SVN with PhpStorm, it cannot handle the svn+ssh authentication. It is possible to use TortoiseSVN 1.8 but always sticking the 1.7 format in PhpStorm.
My final solution was to install TortoiseSVN 1.7, so that I can use it from the Windows menu as well and no formatting issues happen. Another setting necessary for me was unchecking the option under Version Control > Subversion.
[] Use command line client: svn
As the ssh executable, I use:
C:\Program Files (x86)\PuTTY\plink.exe

Setting Windows PATH for Postgres tools

I cannot access PostgreSQL through the command line in Windows. Although I am able to create and update the databases, access them through PGAdminIII, and push to Heroku, I am unable to access them directly through my command line using the psql command.
When I try to create a database by using the command
$ createdb mydb
as explained in the PG documentation, I get the message
createdb: command not found
The documentation suggests that in this case, "PostgreSQL was not installed properly. Try calling the command with an absolute path instead." Sure enough, I am able to create a database by entering the direct path to the file:
$ c:/postgreSQL/9.1/bin/createdb mydb
Does this mean that the path can be reconfigured to connect correctly? Or do I need to reinstall? I've reinstalled several times, and have not been able to set the correct path. I currently have both the /bin and /lib paths addedto my system and user(:Umezo) paths, but still no access from the command line.
User variables for umezo
variable name: Path
variable value: C:\PostgreSQL\9.1\bin; C:\PostgreSQL\9.1\lib
System variables
variable name: Path
variable value: C:\PostgreSQL\9.1\bin; C:\PostgreSQL\9.1\lib
Any information or feedback regarding how I can fix my installment would be appreciated.
My info is as below:
I mostly followed these sources here and here. I installed a 32 bit version of 9.1 because some sources suggested issues with 64 bit.
PG download version: Installer Version 9.1 Win x86-32
Operating System: Windows 7 (64 bit)
pg_hba.conf
#TYPE DATABASE USER CIER-ADDRESS METHOD
# IPv4 local connections:
host all all 127.0.0.1/32 md5
# IPv6 local connections:
host all all ::1/128 md5
postgresql.conf
# - Connection Settings -
listen_addresses = '*'
port = 5432
max_connections = 100
pg_ident.conf
# *Everything is commented out*
Login Role Umezo #from properties window in PGAdminIII
Properties/Role name: Umezo
Properties/Can login: "check"
Role privileges: all categories "check"
configuring postreSQL PATH variable on Windows 7
I encountered this issue too. I'm using Git Bash, hence the Unix-style $ prompt on Windows.
$ rails db
Couldn't find database client: psql, psql.exe. Check your $PATH and try again.
Here's what I did:
In Windows 7, navigate to:
Control Panel
All Control Panel Items
System
Advanced System Settings
Environment Variables
from the System Variables box select "PATH"
Edit...
Then append this string to the existing PATH Variable Value:
;C:\Program Files\PostgreSQL\9.2\bin
and click "OK" three times to exit the menus.
Now, close the console and restart it.
Navigate back to the directory of your Rails app. In my case, this is accomplished with:
$ cd rails_projects/sample_app
Then, try again:
$ rails db
sources:
How do I put PostgreSQL /bin directory on my path in Windows?
http://railscasts.com/episodes/342-migrating-to-postgresql?view=asciicast
Settings Windows Path For Postgresql
open my Computer ==>
right click inside my computer and select properties ==>
Click on Advanced System Settings ==>
Environment Variables ==>
from the System Variables box select "PATH" ==>
Edit... ==>
then add this at the end of whatever you find their
;C:\PostgreSQL\9.2\bin; C:\PostgreSQL\9.2\lib
after that continue to click OK
open cmd/command prompt.... open psql in command prompt with this
psql -U username database
eg. i have a database name FRIENDS and a user MEE.. it will be
psql -U MEE FRIENDS
you will be then prompted to give the password of the user in question.
Thanks
Set path For PostgreSQL in Windows:
Searching for env will show Edit environment variables for your account
Select Environment Variables
From the System Variables box select PATH
Click New (to add new path)
Change the PATH variable to include the bin directory of your PostgreSQL installation.
then add new path their....[for example]
C:\Program Files\PostgreSQL\12\bin
After that click OK
Open CMD/Command Prompt. Type this to open psql
psql -U username database_name
For Example psql -U postgres test
Now, you will be prompted to give Password for the User. (It will be hidden as a security measure).
Then you are good to go.
All you need to do is to change the PATH variable to include the bin directory of your PostgreSQL installation.
An explanation on how to change environment variables is here:
http://support.microsoft.com/kb/310519
http://www.computerhope.com/issues/ch000549.htm
To verify that the path is set correctly, you can use:
echo %PATH%
on the commandline.
On Postgres 9.6(PgAdmin 4) , this can be set up in Preferences->Paths->Binary paths:
- set PostgreSQL Binary Path variable to "C:\Program Files\PostgreSQL\9.6\bin" or where you have installed
In order to connect my git bash to the postgreSQL, I had to add at least 4 environment variables to the windows. Git, Node.js, System 32 and postgreSQL. This is what I set as the value for the Path variable: C:\Windows\System32;C:\Program Files\Git\cmd;C:\Program Files\nodejs;C:\Program Files\PostgreSQL\12\bin; and It works perfectly.
Set Environment in Windows
Our createdbfile exists in this marked folder .so copy this folder path and paste inside environment variables setting under system variables.
start -> Environment Variables
select Environment variable
Create a new environment variable like this
Add environment variable postgres as %postgres% in the path variable
Now check by taking a new command prompt and typing conda (close already opened terminal or cmd)
Now live
Incase any one still wondering how to add environment variables then please use this link to add variables.
Link: https://sqlbackupandftp.com/blog/setting-windows-path-for-postgres-tools
I am using Windows 8 and the above solutions did not work out for me. I downgraded Postgres from 9.4 to 9.3. Man,it worked :)

How do I configure go command to use a proxy?

I want to run go install to install the tour, but I can't find the option to use a proxy for internet access. I don't need this just for the tour but for developing in Go in general.
How do I configure Go to use a proxy.
Go programs understand environment variables http_proxy and no_proxy, but that's not enough because go get uses source control managers for retrieving code. So you have to set HTTP proxy settings for your SCM too. Use this for Mercurial and this for Git.
http_proxy value can be like http://user:password#host:port/. User, password, and port parts are optional. no_proxy is a comma-separated list of servers that should not be connected through proxy. Its value can be like foo.com,bar.net:4000.
You can set these environment variables in your bash_profile, but if you want to limit their usage to go, you can run it like this:
$ http_proxy=127.0.0.1:8080 go get code.google.com/p/go.crypto/bcrypt
If that's what you always want, set this alias to avoid typing proxy part every time:
$ alias go='http_proxy=127.0.0.1:8080 go'
From now on you can use go normally, but it uses your HTTP proxy.
On Windows command line:
set http_proxy=http://[user]:[pass]#[proxy_ip]:[proxy_port]/
set https_proxy=http://[user]:[pass]#[proxy_ip]:[proxy_port]/
...then navigate to https://github.com/ and download the GitHub certificate (I set the name as goland_cert.cer)
...now execute the OpenSSL command to export this to PEM format
openssl x509 -inform der -in goland_cert.cer -out goland_cert.pem
...finally set the certificate in git global config
git config --global http.sslCAInfo C:/Users/[User]/certs/golang_cert.pem
This works for me:
alias go='http_proxy=http://127.0.0.1:1081/ https_proxy=http://127.0.0.1:1081/ no_proxy=localhost,127.0.0.0/8,::1 go'
Note: for someones, protocol may be different https_proxy=http://127.0.0.1:1081
you can also map http requests to socks5 traffic by using https://github.com/cyfdecyf/cow/
very handy if you are blocked by GFW
Add GOPROXY variable name and Variable value as your proxy in the System variable. This worked for me.
You may want check https://github.com/hmgle/graftcp,
$ graftcp-local/graftcp-local -h
Usage of graftcp-local/graftcp-local:
-config string
Path to the configuration file
-listen string
Listen address (default ":2233")
-logfile string
Write logs to file
-loglevel value
Log level (0-6) (default 1)
-pipepath string
Pipe path for graftcp to send address info (default "/tmp/graftcplocal.fifo")
-service string
Control the system service: ["start" "stop" "restart" "install" "uninstall"]
-socks5 string
SOCKS5 address (default "127.0.0.1:1080")
-syslog
Send logs to the local system logger (Eventlog on Windows, syslog on Unix)
If you already have shadowsocks listening on 1080, then you don't need provide any paramaters, just run graftcp-local, to proxy go get
$ ./graftcp go get -v golang.org/x/net/proxy
I solved this problem with the Go command setting some variables in the Win10 system.
Here ("Using the cf CLI with a Proxy Server") you can find the information described below, with images. Also you can read information about:
Format of https_proxy
Use SOCKS5 with cf v3-ssh
Set https_proxy in Mac OS or Linux
I included in this answer only information about W10 because is the one I tested.
Windows 10
Set the new path variable.
From the search box, type in path
Select and open "Edit the system environment variables (control panel)".
"System properties" window will open.
Select "Advanced" tab.
Press "Environment Variables" button, a window with the same name will open.
In "System Variables" section, press the "New" button. "New System Variable" window will open.
You'll now add the needed variable, fill the fields as follows:
Variable name: https_proxy
Variable value:http://yourUserName:userNamePassword#yourIPaddress:port
Lastly...
I tested the installation command line for go.
Open the console, and type in: go install github.com/isacikgoz/gitbatch/cmd/gitbatch#latest
That's an example from this project: https://github.com/isacikgoz/gitbatch
This worked on my particular W10 19043 system.
git config [--global] http.proxy http://proxy.example.com:port
git config [--global] https.proxy http://proxy.example.com:port
see https://github.com/golang/go/wiki/GoGetProxyConfig

Resources