mirror of
https://github.com/onionshare/onionshare.git
synced 2024-12-17 19:54:48 -05:00
Merge pull request #1552 from mig5/better_meek_logs
More verbose and consistent Meek exception logging
This commit is contained in:
commit
fbcad47138
@ -19,8 +19,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|||||||
"""
|
"""
|
||||||
import requests
|
import requests
|
||||||
|
|
||||||
from .meek import MeekNotRunning
|
|
||||||
|
|
||||||
|
|
||||||
class CensorshipCircumventionError(Exception):
|
class CensorshipCircumventionError(Exception):
|
||||||
"""
|
"""
|
||||||
@ -47,15 +45,12 @@ class CensorshipCircumvention(object):
|
|||||||
self.api_proxies = {}
|
self.api_proxies = {}
|
||||||
if meek:
|
if meek:
|
||||||
self.meek = meek
|
self.meek = meek
|
||||||
if not self.meek.meek_proxies:
|
self.common.log(
|
||||||
raise MeekNotRunning()
|
"CensorshipCircumvention",
|
||||||
else:
|
"__init__",
|
||||||
self.common.log(
|
"Using Meek with CensorshipCircumvention API",
|
||||||
"CensorshipCircumvention",
|
)
|
||||||
"__init__",
|
self.api_proxies = self.meek.meek_proxies
|
||||||
"Using Meek with CensorshipCircumvention API",
|
|
||||||
)
|
|
||||||
self.api_proxies = self.meek.meek_proxies
|
|
||||||
if onion:
|
if onion:
|
||||||
self.onion = onion
|
self.onion = onion
|
||||||
if not self.onion.is_authenticated:
|
if not self.onion.is_authenticated:
|
||||||
|
@ -69,7 +69,7 @@ class Meek(object):
|
|||||||
if self.meek_client_file_path is None or not os.path.exists(
|
if self.meek_client_file_path is None or not os.path.exists(
|
||||||
self.meek_client_file_path
|
self.meek_client_file_path
|
||||||
):
|
):
|
||||||
raise MeekNotFound()
|
raise MeekNotFound(self.common)
|
||||||
|
|
||||||
# Start the Meek Client as a subprocess.
|
# Start the Meek Client as a subprocess.
|
||||||
self.common.log("Meek", "start", "Starting meek client")
|
self.common.log("Meek", "start", "Starting meek client")
|
||||||
@ -128,7 +128,7 @@ class Meek(object):
|
|||||||
|
|
||||||
if "CMETHOD-ERROR" in line:
|
if "CMETHOD-ERROR" in line:
|
||||||
self.cleanup()
|
self.cleanup()
|
||||||
raise MeekNotRunning()
|
raise MeekNotRunning(self.common, line)
|
||||||
break
|
break
|
||||||
|
|
||||||
if self.meek_port:
|
if self.meek_port:
|
||||||
@ -137,9 +137,8 @@ class Meek(object):
|
|||||||
"https": f"socks5h://{self.meek_host}:{self.meek_port}",
|
"https": f"socks5h://{self.meek_host}:{self.meek_port}",
|
||||||
}
|
}
|
||||||
else:
|
else:
|
||||||
self.common.log("Meek", "start", "Could not obtain the meek port")
|
|
||||||
self.cleanup()
|
self.cleanup()
|
||||||
raise MeekNotRunning()
|
raise MeekNotRunning(self.common, "Could not obtain the meek port")
|
||||||
|
|
||||||
def cleanup(self):
|
def cleanup(self):
|
||||||
"""
|
"""
|
||||||
@ -182,8 +181,19 @@ class MeekNotRunning(Exception):
|
|||||||
number it started on, in order to do domain fronting.
|
number it started on, in order to do domain fronting.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
def __init__(self, common, info=None):
|
||||||
|
self.common = common
|
||||||
|
msg = "Meek experienced an error starting up"
|
||||||
|
if info:
|
||||||
|
msg = msg + f": {info}"
|
||||||
|
self.common.log("MeekNotRunning", "__init__", msg)
|
||||||
|
|
||||||
|
|
||||||
class MeekNotFound(Exception):
|
class MeekNotFound(Exception):
|
||||||
"""
|
"""
|
||||||
We were unable to find the Meek Client binary.
|
We were unable to find the Meek Client binary.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
def __init__(self, common):
|
||||||
|
self.common = common
|
||||||
|
self.common.log("MeekNotFound", "__init__", "Could not find the meek binary")
|
||||||
|
@ -181,6 +181,11 @@ class AutoConnectTab(QtWidgets.QWidget):
|
|||||||
self.tor_con.start(self.curr_settings)
|
self.tor_con.start(self.curr_settings)
|
||||||
|
|
||||||
def _got_no_bridges(self):
|
def _got_no_bridges(self):
|
||||||
|
self.common.log(
|
||||||
|
"AutoConnectTab",
|
||||||
|
"_got_no_bridges",
|
||||||
|
"Could not obtain bridges, so falling back to trying built-in obfs4 bridges",
|
||||||
|
)
|
||||||
# If we got no bridges, try connecting again using built-in obfs4 bridges
|
# If we got no bridges, try connecting again using built-in obfs4 bridges
|
||||||
self.curr_settings.set("bridges_type", "built-in")
|
self.curr_settings.set("bridges_type", "built-in")
|
||||||
self.curr_settings.set("bridges_builtin_pt", "obfs4")
|
self.curr_settings.set("bridges_builtin_pt", "obfs4")
|
||||||
|
@ -236,14 +236,10 @@ class MoatThread(QtCore.QThread):
|
|||||||
# Start Meek so that we can do domain fronting
|
# Start Meek so that we can do domain fronting
|
||||||
try:
|
try:
|
||||||
self.meek.start()
|
self.meek.start()
|
||||||
except MeekNotFound:
|
except (
|
||||||
self.common.log("MoatThread", "run", f"Could not find meek-client")
|
MeekNotFound,
|
||||||
self.bridgedb_error.emit()
|
MeekNotRunning,
|
||||||
return
|
):
|
||||||
except MeekNotRunning:
|
|
||||||
self.common.log(
|
|
||||||
"MoatThread", "run", f"Ran meek-client, but there was an error"
|
|
||||||
)
|
|
||||||
self.bridgedb_error.emit()
|
self.bridgedb_error.emit()
|
||||||
return
|
return
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user