Skip to content
This repository was archived by the owner on Dec 18, 2022. It is now read-only.

Commit 74d1949

Browse files
committed
add new class that extends capabilities of the EventBroadcaster for updating the application with addresses Tor is operating on
1 parent ec860f3 commit 74d1949

File tree

2 files changed

+120
-1
lines changed

2 files changed

+120
-1
lines changed

topl-service/build.gradle

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,8 @@ dokka {
4444
includeNonPublic = false
4545
skipEmptyPackages = true
4646
samples = [
47-
"$rootDir/sampleapp/src/main/java/io/matthewnelson/sampleapp/App.kt".toString()
47+
"$rootDir/sampleapp/src/main/java/io/matthewnelson/sampleapp/App.kt".toString(),
48+
"$rootDir/sampleapp/src/main/java/io/matthewnelson/sampleapp/MyEventBroadcaster.kt".toString()
4849
]
4950
sourceLink {
5051
url = "https://github.com/05nelsonm/TorOnionProxyLibrary-Android/blob/master/"
Lines changed: 118 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,118 @@
1+
/*
2+
* TorOnionProxyLibrary-Android (a.k.a. topl-android) is a derivation of
3+
* work from the Tor_Onion_Proxy_Library project that started at commit
4+
* hash `74407114cbfa8ea6f2ac51417dda8be98d8aba86`. Contributions made after
5+
* said commit hash are:
6+
*
7+
* Copyright (C) 2020 Matthew Nelson
8+
*
9+
* This program is free software: you can redistribute it and/or modify it
10+
* under the terms of the GNU General Public License as published by the
11+
* Free Software Foundation, either version 3 of the License, or (at your
12+
* option) any later version.
13+
*
14+
* This program is distributed in the hope that it will be useful, but
15+
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
16+
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
17+
* for more details.
18+
*
19+
* You should have received a copy of the GNU General Public License
20+
* along with this program. If not, see <https://www.gnu.org/licenses/>.
21+
*
22+
* `===========================================================================`
23+
* `+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++`
24+
* `===========================================================================`
25+
*
26+
* The following exception is an additional permission under section 7 of the
27+
* GNU General Public License, version 3 (“GPLv3”).
28+
*
29+
* "The Interfaces" is henceforth defined as Application Programming Interfaces
30+
* that are publicly available classes/functions/etc (ie: do not contain the
31+
* visibility modifiers `internal`, `private`, `protected`, or are within
32+
* classes/functions/etc that contain the aforementioned visibility modifiers)
33+
* to TorOnionProxyLibrary-Android users that are needed to implement
34+
* TorOnionProxyLibrary-Android and reside in ONLY the following modules:
35+
*
36+
* - topl-core-base
37+
* - topl-service
38+
*
39+
* The following are excluded from "The Interfaces":
40+
*
41+
* - All other code
42+
*
43+
* Linking TorOnionProxyLibrary-Android statically or dynamically with other
44+
* modules is making a combined work based on TorOnionProxyLibrary-Android.
45+
* Thus, the terms and conditions of the GNU General Public License cover the
46+
* whole combination.
47+
*
48+
* As a special exception, the copyright holder of TorOnionProxyLibrary-Android
49+
* gives you permission to combine TorOnionProxyLibrary-Android program with free
50+
* software programs or libraries that are released under the GNU LGPL and with
51+
* independent modules that communicate with TorOnionProxyLibrary-Android solely
52+
* through "The Interfaces". You may copy and distribute such a system following
53+
* the terms of the GNU GPL for TorOnionProxyLibrary-Android and the licenses of
54+
* the other code concerned, provided that you include the source code of that
55+
* other code when and as the GNU GPL requires distribution of source code and
56+
* provided that you do not modify "The Interfaces".
57+
*
58+
* Note that people who make modified versions of TorOnionProxyLibrary-Android
59+
* are not obligated to grant this special exception for their modified versions;
60+
* it is their choice whether to do so. The GNU General Public License gives
61+
* permission to release a modified version without this exception; this exception
62+
* also makes it possible to release a modified version which carries forward this
63+
* exception. If you modify "The Interfaces", this exception does not apply to your
64+
* modified version of TorOnionProxyLibrary-Android, and you must remove this
65+
* exception when you distribute your modified version.
66+
* */
67+
package io.matthewnelson.topl_service.service.components.onionproxy
68+
69+
import io.matthewnelson.topl_core_base.EventBroadcaster
70+
71+
/**
72+
* Adds broadcasting methods to the [EventBroadcaster] to update you with information about
73+
* what addresses Tor is operating on. Very helpful when choosing "auto" in your
74+
* [io.matthewnelson.topl_core_base.TorSettings] to easily identifying what addresses to
75+
* use for making network calls, as well as being notified when Tor is ready to be used.
76+
*
77+
* The addresses will be broadcast to you after Tor has been fully Bootstrapped. If Tor is
78+
* stopped (ie. it's [io.matthewnelson.topl_core_base.BaseConsts.TorState] changes from **ON**
79+
* to **OFF**), `null` will be broadcast.
80+
*
81+
* All broadcasts to your implementation to this class will occur on the Main thread.
82+
*
83+
* @sample [io.matthewnelson.sampleapp.MyEventBroadcaster]
84+
* */
85+
abstract class TorServiceEventBroadcaster: EventBroadcaster() {
86+
87+
/**
88+
* Override this method to implement receiving of the control port address that Tor
89+
* is operating on.
90+
*
91+
* Example of what will be broadcast:
92+
*
93+
* - "127.0.0.1:33432"
94+
* */
95+
abstract fun broadcastControlPortAddress(controlPortAddress: String?)
96+
97+
/**
98+
* Override this method to implement receiving of the Socks port address that Tor
99+
* is operating on (if you've specified a
100+
* [io.matthewnelson.topl_core_base.TorSettings.socksPort]).
101+
*
102+
* Example of what will be broadcast:
103+
*
104+
* - "127.0.0.1:9051"
105+
* */
106+
abstract fun broadcastSocksPortAddress(socksPortAddress: String?)
107+
108+
/**
109+
* Override this method to implement receiving of the http port address that Tor
110+
* is operating on (if you've specified a
111+
* [io.matthewnelson.topl_core_base.TorSettings.httpTunnelPort]).
112+
*
113+
* Example of what will be broadcast:
114+
*
115+
* - "127.0.0.1:33432"
116+
* */
117+
abstract fun broadcastHttpPortAddress(httpPortAddress: String?)
118+
}

0 commit comments

Comments
 (0)