communicator now uses one function
This commit is contained in:
		
							parent
							
								
									d0a93ef2de
								
							
						
					
					
						commit
						4d33005d16
					
				
					 3 changed files with 16 additions and 1 deletions
				
			
		| 
						 | 
				
			
			@ -129,6 +129,8 @@ class API:
 | 
			
		|||
                pass
 | 
			
		||||
            elif action == 'getPGP':
 | 
			
		||||
                resp = Response(self._utils.exportMyPubkey())
 | 
			
		||||
            elif action == 'storeData':
 | 
			
		||||
                pass
 | 
			
		||||
 | 
			
		||||
            return resp
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -69,6 +69,19 @@ class OnionrCommunicate:
 | 
			
		|||
    def sendPeerProof(self, peerID, data):
 | 
			
		||||
        '''This function sends the proof result to a peer previously fetched with getPeerProof'''
 | 
			
		||||
        return
 | 
			
		||||
    def performGet(self, action, peer, data=None, type='tor'):
 | 
			
		||||
        '''performs a request to a peer through Tor or i2p (currently only tor)'''
 | 
			
		||||
        if not peer.endswith('.onion') and not peer.endswith('.onion/'):
 | 
			
		||||
            raise PeerError('Currently only Tor .onion peers are supported. You must manually specify .onion')
 | 
			
		||||
        socksPort = sys.argv[2]
 | 
			
		||||
        proxies = {'http': 'socks5://127.0.0.1:' + str(socksPort), 'https': 'socks5://127.0.0.1:' + str(socksPort)}
 | 
			
		||||
        headers = {'user-agent': 'PyOnionr'}
 | 
			
		||||
        url = 'http://' + peer + '/public/?action=' + action
 | 
			
		||||
        if data != None:
 | 
			
		||||
            url = url + '&data=' + data
 | 
			
		||||
        r = requests.get(url, headers=headers, proxies=proxies)
 | 
			
		||||
        return r.text
 | 
			
		||||
        
 | 
			
		||||
 | 
			
		||||
shouldRun = False
 | 
			
		||||
debug = False
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -128,7 +128,7 @@ class Onionr:
 | 
			
		|||
            net.startTor()
 | 
			
		||||
            print(colors.GREEN + 'Started Tor .onion service: ' + colors.UNDERLINE + net.myID + colors.RESET)
 | 
			
		||||
            time.sleep(1)
 | 
			
		||||
            subprocess.Popen(["./communicator.py", "run"])
 | 
			
		||||
            subprocess.Popen(["./communicator.py", "run", net.socksPort])
 | 
			
		||||
            print('Started communicator')
 | 
			
		||||
        api.API(self.config, self.debug)
 | 
			
		||||
        return
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue