Skip to content
This repository has been archived by the owner on Nov 13, 2020. It is now read-only.

Using Tor with pyogame2

PiecePaperCode edited this page Jan 25, 2020 · 1 revision

using Tor with pyogame2

assuming that you have already installed the tor program on your computer and having a localhost: 9050 ready to connect to. For some reason trying to connect python3 on a raspberry pie to the tor proxy always errors out because it can't speak socks5.

On windows it works with the building proxy setting from the request. session lib.

empire = OGame2('UNI', 'Email@Email.com', 'password', proxy='socks5://localhost:9050')

but if you want to run in on a raspberry pie you gonna have problems in connecting to tor. the solution is to monkey patch the standard socks library. Normally it is not recommended to do that, but because I am running a raspberry pi only with that task for playing the game for me it will be working fine to achieve this goal.

  1. Download socks.py from this lib and rename it to socks5.py and place it in the same path where your script is. https://github.com/Anorov/PySocks
  2. Now you can use it like this
import socket
import socks5

socks5.set_default_proxy(socks5.SOCKS5, "localhost", 9050)
socket.socket = socks5.socksocket
empire = OGame2('UNI', 'Email@Email.com', 'password', proxy='')

this will force all session calls to go over the tor network. Be carefull because you cant make local calls to your home network anymore. everything goes to tor.