Commits:
4 changed files:
Changes:
mobile/android/geckoview/src/main/java/org/mozilla/geckoview/TorIntegrationAndroid.java
... |
... |
@@ -46,6 +46,7 @@ public class TorIntegrationAndroid implements BundleEventListener { |
46
|
46
|
private static final String EVENT_BOOTSTRAP_PROGRESS = "GeckoView:Tor:BootstrapProgress";
|
47
|
47
|
private static final String EVENT_BOOTSTRAP_COMPLETE = "GeckoView:Tor:BootstrapComplete";
|
48
|
48
|
private static final String EVENT_BOOTSTRAP_ERROR = "GeckoView:Tor:BootstrapError";
|
|
49
|
+ private static final String EVENT_TOR_LOGS = "GeckoView:Tor:Logs";
|
49
|
50
|
private static final String EVENT_SETTINGS_READY = "GeckoView:Tor:SettingsReady";
|
50
|
51
|
private static final String EVENT_SETTINGS_CHANGED = "GeckoView:Tor:SettingsChanged";
|
51
|
52
|
private static final String EVENT_SETTINGS_OPEN = "GeckoView:Tor:OpenSettings";
|
... |
... |
@@ -118,6 +119,7 @@ public class TorIntegrationAndroid implements BundleEventListener { |
118
|
119
|
EVENT_BOOTSTRAP_PROGRESS,
|
119
|
120
|
EVENT_BOOTSTRAP_COMPLETE,
|
120
|
121
|
EVENT_BOOTSTRAP_ERROR,
|
|
122
|
+ EVENT_TOR_LOGS,
|
121
|
123
|
EVENT_SETTINGS_OPEN);
|
122
|
124
|
}
|
123
|
125
|
|
... |
... |
@@ -168,6 +170,12 @@ public class TorIntegrationAndroid implements BundleEventListener { |
168
|
170
|
for (BootstrapStateChangeListener listener: mBootstrapStateListeners) {
|
169
|
171
|
listener.onBootstrapError(msg, details);
|
170
|
172
|
}
|
|
173
|
+ } else if (EVENT_TOR_LOGS.equals(event)) {
|
|
174
|
+ String msg = message.getString("message");
|
|
175
|
+ String type = message.getString("logType");
|
|
176
|
+ for (TorLogListener listener: mLogListeners) {
|
|
177
|
+ listener.onLog(type, msg);
|
|
178
|
+ }
|
171
|
179
|
} else if (EVENT_SETTINGS_OPEN.equals(event)) {
|
172
|
180
|
for (BootstrapStateChangeListener listener: mBootstrapStateListeners) {
|
173
|
181
|
listener.onSettingsRequested();
|
... |
... |
@@ -573,6 +581,10 @@ public class TorIntegrationAndroid implements BundleEventListener { |
573
|
581
|
void onSettingsRequested();
|
574
|
582
|
}
|
575
|
583
|
|
|
584
|
+ public interface TorLogListener {
|
|
585
|
+ void onLog(String logType, String message);
|
|
586
|
+ }
|
|
587
|
+
|
576
|
588
|
private @NonNull void reloadSettings() {
|
577
|
589
|
EventDispatcher.getInstance().queryBundle(EVENT_SETTINGS_GET).then( new GeckoResult.OnValueListener<GeckoBundle, Void>() {
|
578
|
590
|
public GeckoResult<Void> onValue(final GeckoBundle bundle) {
|
... |
... |
@@ -647,4 +659,14 @@ public class TorIntegrationAndroid implements BundleEventListener { |
647
|
659
|
}
|
648
|
660
|
|
649
|
661
|
private final HashSet<BootstrapStateChangeListener> mBootstrapStateListeners = new HashSet<>();
|
|
662
|
+
|
|
663
|
+ public void registerLogListener(TorLogListener listener) {
|
|
664
|
+ mLogListeners.add(listener);
|
|
665
|
+ }
|
|
666
|
+
|
|
667
|
+ public void unregisterLogListener(TorLogListener listener) {
|
|
668
|
+ mLogListeners.remove(listener);
|
|
669
|
+ }
|
|
670
|
+
|
|
671
|
+ private final HashSet<TorLogListener> mLogListeners = new HashSet<>();
|
650
|
672
|
} |
toolkit/components/tor-launcher/TorProvider.sys.mjs
... |
... |
@@ -1002,6 +1002,8 @@ export class TorProvider { |
1002
|
1002
|
Services.obs.notifyObservers(null, TorProviderTopics.HasWarnOrErr);
|
1003
|
1003
|
}
|
1004
|
1004
|
|
|
1005
|
+ Services.obs.notifyObservers({ type, msg }, TorProviderTopics.TorLog);
|
|
1006
|
+
|
1005
|
1007
|
const date = new Date();
|
1006
|
1008
|
const maxEntries = Services.prefs.getIntPref(
|
1007
|
1009
|
Preferences.MaxLogEntries,
|
toolkit/components/tor-launcher/TorProviderBuilder.sys.mjs
... |
... |
@@ -12,6 +12,7 @@ export const TorProviderTopics = Object.freeze({ |
12
|
12
|
ProcessExited: "TorProcessExited",
|
13
|
13
|
BootstrapStatus: "TorBootstrapStatus",
|
14
|
14
|
BootstrapError: "TorBootstrapError",
|
|
15
|
+ TorLog: "TorLog",
|
15
|
16
|
HasWarnOrErr: "TorLogHasWarnOrErr",
|
16
|
17
|
BridgeChanged: "TorBridgeChanged",
|
17
|
18
|
CircuitCredentialsMatched: "TorCircuitCredentialsMatched",
|
toolkit/modules/TorAndroidIntegration.sys.mjs
... |
... |
@@ -11,6 +11,7 @@ ChromeUtils.defineESModuleGetters(lazy, { |
11
|
11
|
TorConnectTopics: "resource://gre/modules/TorConnect.sys.mjs",
|
12
|
12
|
TorSettingsTopics: "resource://gre/modules/TorSettings.sys.mjs",
|
13
|
13
|
TorProviderBuilder: "resource://gre/modules/TorProviderBuilder.sys.mjs",
|
|
14
|
+ TorProviderTopics: "resource://gre/modules/TorProviderBuilder.sys.mjs",
|
14
|
15
|
TorSettings: "resource://gre/modules/TorSettings.sys.mjs",
|
15
|
16
|
});
|
16
|
17
|
|
... |
... |
@@ -32,6 +33,7 @@ const EmittedEvents = Object.freeze({ |
32
|
33
|
bootstrapProgress: "GeckoView:Tor:BootstrapProgress",
|
33
|
34
|
bootstrapComplete: "GeckoView:Tor:BootstrapComplete",
|
34
|
35
|
bootstrapError: "GeckoView:Tor:BootstrapError",
|
|
36
|
+ torLogs: "GeckoView:Tor:Logs",
|
35
|
37
|
});
|
36
|
38
|
|
37
|
39
|
const ListenedEvents = Object.freeze({
|
... |
... |
@@ -59,6 +61,8 @@ class TorAndroidIntegrationImpl { |
59
|
61
|
this.#bootstrapMethodReset();
|
60
|
62
|
Services.prefs.addObserver(Prefs.useNewBootstrap, this);
|
61
|
63
|
|
|
64
|
+ Services.obs.addObserver(this, lazy.TorProviderTopics.TorLog);
|
|
65
|
+
|
62
|
66
|
for (const topic in lazy.TorConnectTopics) {
|
63
|
67
|
Services.obs.addObserver(this, lazy.TorConnectTopics[topic]);
|
64
|
68
|
}
|
... |
... |
@@ -118,6 +122,13 @@ class TorAndroidIntegrationImpl { |
118
|
122
|
details: subj.wrappedJSObject.details ?? "",
|
119
|
123
|
});
|
120
|
124
|
break;
|
|
125
|
+ case lazy.TorProviderTopics.TorLog:
|
|
126
|
+ lazy.EventDispatcher.instance.sendRequest({
|
|
127
|
+ type: EmittedEvents.torLogs,
|
|
128
|
+ logType: subj.wrappedJSObject.type ?? "",
|
|
129
|
+ message: subj.wrappedJSObject.msg ?? "",
|
|
130
|
+ });
|
|
131
|
+ break;
|
121
|
132
|
case lazy.TorSettingsTopics.Ready:
|
122
|
133
|
lazy.EventDispatcher.instance.sendRequest({
|
123
|
134
|
type: EmittedEvents.settingsReady,
|
|