forked from meejah/txtorcon
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix plugin, endpoint constructor and parser
Endpoint parser code moved out of the plugin and into txtorcon. Plugin file is now a minimal 2 lines of code. Parsing logic moved out of constructor and into the parser. The parser creates a TorConfig object and passes it to the constructor.
- Loading branch information
Showing
2 changed files
with
65 additions
and
70 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,27 +1,4 @@ | ||
| #!/usr/bin/env python | ||
|
|
||
| from zope.interface import implementer | ||
| from twisted.plugin import IPlugin | ||
| from twisted.internet.protocol import Protocol, Factory | ||
| from twisted.internet import reactor | ||
| from twisted.internet.interfaces import IStreamServerEndpointStringParser | ||
| from twisted.internet.endpoints import serverFromString | ||
| from txtorcon.torconfig import TCPHiddenServiceEndpointParser | ||
|
|
||
| import txtorcon | ||
|
|
||
|
|
||
| @implementer(IPlugin, IStreamServerEndpointStringParser) | ||
| class TorHiddenServiceEndpointStringParser(object): | ||
| prefix = "onion" | ||
|
|
||
| def _parseServer(self, reactor, publicPort=None, localPort=None, controlPort=None, socksPort=None, hiddenServiceDir=None): | ||
|
|
||
| assert publicPort is not None | ||
|
|
||
| return txtorcon.TCPHiddenServiceEndpoint(reactor, publicPort=publicPort, localPort=localPort, controlPort=controlPort, socksPort=socksPort, hiddenServiceDir=hiddenServiceDir) | ||
|
|
||
| def parseStreamServer(self, reactor, *args, **kwargs): | ||
| return self._parseServer(reactor, *args, **kwargs) | ||
|
|
||
|
|
||
| torHiddenServiceEndpointStringParser = TorHiddenServiceEndpointStringParser() | ||
| tcpHiddenServiceEndpointParser = TCPHiddenServiceEndpointParser() |
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