Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
briar
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
briar
briar
Commits
ba19716e
Verified
Commit
ba19716e
authored
6 years ago
by
akwizgran
Browse files
Options
Downloads
Patches
Plain Diff
Don't broadcast disabled event whenever we close a socket.
parent
41deff1b
No related branches found
No related tags found
1 merge request
!1125
Publish hidden service for connecting to pending contact
Pipeline
#3475
passed
6 years ago
Stage: test
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
bramble-core/src/main/java/org/briarproject/bramble/plugin/tor/TorPlugin.java
+10
-15
10 additions, 15 deletions
...n/java/org/briarproject/bramble/plugin/tor/TorPlugin.java
with
10 additions
and
15 deletions
bramble-core/src/main/java/org/briarproject/bramble/plugin/tor/TorPlugin.java
+
10
−
15
View file @
ba19716e
...
@@ -32,7 +32,6 @@ import org.briarproject.bramble.api.settings.event.SettingsUpdatedEvent;
...
@@ -32,7 +32,6 @@ import org.briarproject.bramble.api.settings.event.SettingsUpdatedEvent;
import
org.briarproject.bramble.api.system.Clock
;
import
org.briarproject.bramble.api.system.Clock
;
import
org.briarproject.bramble.api.system.LocationUtils
;
import
org.briarproject.bramble.api.system.LocationUtils
;
import
org.briarproject.bramble.api.system.ResourceProvider
;
import
org.briarproject.bramble.api.system.ResourceProvider
;
import
org.briarproject.bramble.util.IoUtils
;
import
java.io.EOFException
;
import
java.io.EOFException
;
import
java.io.File
;
import
java.io.File
;
...
@@ -55,7 +54,6 @@ import java.util.logging.Logger;
...
@@ -55,7 +54,6 @@ import java.util.logging.Logger;
import
java.util.regex.Pattern
;
import
java.util.regex.Pattern
;
import
java.util.zip.ZipInputStream
;
import
java.util.zip.ZipInputStream
;
import
javax.annotation.Nullable
;
import
javax.net.SocketFactory
;
import
javax.net.SocketFactory
;
import
static
java
.
util
.
Arrays
.
asList
;
import
static
java
.
util
.
Arrays
.
asList
;
...
@@ -79,6 +77,7 @@ import static org.briarproject.bramble.api.plugin.TorConstants.PREF_TOR_PORT;
...
@@ -79,6 +77,7 @@ import static org.briarproject.bramble.api.plugin.TorConstants.PREF_TOR_PORT;
import
static
org
.
briarproject
.
bramble
.
api
.
plugin
.
TorConstants
.
PROP_ONION_V2
;
import
static
org
.
briarproject
.
bramble
.
api
.
plugin
.
TorConstants
.
PROP_ONION_V2
;
import
static
org
.
briarproject
.
bramble
.
api
.
plugin
.
TorConstants
.
PROP_ONION_V3
;
import
static
org
.
briarproject
.
bramble
.
api
.
plugin
.
TorConstants
.
PROP_ONION_V3
;
import
static
org
.
briarproject
.
bramble
.
util
.
IoUtils
.
copyAndClose
;
import
static
org
.
briarproject
.
bramble
.
util
.
IoUtils
.
copyAndClose
;
import
static
org
.
briarproject
.
bramble
.
util
.
IoUtils
.
tryToClose
;
import
static
org
.
briarproject
.
bramble
.
util
.
LogUtils
.
logException
;
import
static
org
.
briarproject
.
bramble
.
util
.
LogUtils
.
logException
;
import
static
org
.
briarproject
.
bramble
.
util
.
PrivacyUtils
.
scrubOnion
;
import
static
org
.
briarproject
.
bramble
.
util
.
PrivacyUtils
.
scrubOnion
;
import
static
org
.
briarproject
.
bramble
.
util
.
StringUtils
.
isNullOrEmpty
;
import
static
org
.
briarproject
.
bramble
.
util
.
StringUtils
.
isNullOrEmpty
;
...
@@ -314,8 +313,8 @@ abstract class TorPlugin implements DuplexPlugin, EventHandler, EventListener {
...
@@ -314,8 +313,8 @@ abstract class TorPlugin implements DuplexPlugin, EventHandler, EventListener {
if
(!
doneFile
.
createNewFile
())
if
(!
doneFile
.
createNewFile
())
LOG
.
warning
(
"Failed to create done file"
);
LOG
.
warning
(
"Failed to create done file"
);
}
catch
(
IOException
e
)
{
}
catch
(
IOException
e
)
{
IoUtils
.
tryToClose
(
in
,
LOG
,
WARNING
);
tryToClose
(
in
,
LOG
,
WARNING
);
IoUtils
.
tryToClose
(
out
,
LOG
,
WARNING
);
tryToClose
(
out
,
LOG
,
WARNING
);
throw
new
PluginException
(
e
);
throw
new
PluginException
(
e
);
}
}
}
}
...
@@ -374,7 +373,7 @@ abstract class TorPlugin implements DuplexPlugin, EventHandler, EventListener {
...
@@ -374,7 +373,7 @@ abstract class TorPlugin implements DuplexPlugin, EventHandler, EventListener {
}
}
return
b
;
return
b
;
}
finally
{
}
finally
{
IoUtils
.
tryToClose
(
in
,
LOG
,
WARNING
);
tryToClose
(
in
,
LOG
,
WARNING
);
}
}
}
}
...
@@ -392,11 +391,11 @@ abstract class TorPlugin implements DuplexPlugin, EventHandler, EventListener {
...
@@ -392,11 +391,11 @@ abstract class TorPlugin implements DuplexPlugin, EventHandler, EventListener {
ss
.
bind
(
new
InetSocketAddress
(
"127.0.0.1"
,
port
));
ss
.
bind
(
new
InetSocketAddress
(
"127.0.0.1"
,
port
));
}
catch
(
IOException
e
)
{
}
catch
(
IOException
e
)
{
logException
(
LOG
,
WARNING
,
e
);
logException
(
LOG
,
WARNING
,
e
);
tryToClose
(
ss
);
tryToClose
(
ss
,
LOG
,
WARNING
);
return
;
return
;
}
}
if
(!
running
)
{
if
(!
running
)
{
tryToClose
(
ss
);
tryToClose
(
ss
,
LOG
,
WARNING
);
return
;
return
;
}
}
socket
=
ss
;
socket
=
ss
;
...
@@ -413,11 +412,6 @@ abstract class TorPlugin implements DuplexPlugin, EventHandler, EventListener {
...
@@ -413,11 +412,6 @@ abstract class TorPlugin implements DuplexPlugin, EventHandler, EventListener {
});
});
}
}
private
void
tryToClose
(
@Nullable
ServerSocket
ss
)
{
IoUtils
.
tryToClose
(
ss
,
LOG
,
WARNING
);
callback
.
transportDisabled
();
}
private
void
publishHiddenService
(
String
port
)
{
private
void
publishHiddenService
(
String
port
)
{
if
(!
running
)
return
;
if
(!
running
)
return
;
LOG
.
info
(
"Creating hidden service"
);
LOG
.
info
(
"Creating hidden service"
);
...
@@ -502,7 +496,8 @@ abstract class TorPlugin implements DuplexPlugin, EventHandler, EventListener {
...
@@ -502,7 +496,8 @@ abstract class TorPlugin implements DuplexPlugin, EventHandler, EventListener {
@Override
@Override
public
void
stop
()
{
public
void
stop
()
{
running
=
false
;
running
=
false
;
tryToClose
(
socket
);
tryToClose
(
socket
,
LOG
,
WARNING
);
callback
.
transportDisabled
();
if
(
controlSocket
!=
null
&&
controlConnection
!=
null
)
{
if
(
controlSocket
!=
null
&&
controlConnection
!=
null
)
{
try
{
try
{
LOG
.
info
(
"Stopping Tor"
);
LOG
.
info
(
"Stopping Tor"
);
...
@@ -589,7 +584,7 @@ abstract class TorPlugin implements DuplexPlugin, EventHandler, EventListener {
...
@@ -589,7 +584,7 @@ abstract class TorPlugin implements DuplexPlugin, EventHandler, EventListener {
LOG
.
info
(
"Could not connect to "
+
scrubOnion
(
bestOnion
)
LOG
.
info
(
"Could not connect to "
+
scrubOnion
(
bestOnion
)
+
": "
+
e
.
toString
());
+
": "
+
e
.
toString
());
}
}
IoUtils
.
tryToClose
(
s
,
LOG
,
WARNING
);
tryToClose
(
s
,
LOG
,
WARNING
);
return
null
;
return
null
;
}
}
}
}
...
@@ -657,7 +652,7 @@ abstract class TorPlugin implements DuplexPlugin, EventHandler, EventListener {
...
@@ -657,7 +652,7 @@ abstract class TorPlugin implements DuplexPlugin, EventHandler, EventListener {
@Override
@Override
public
void
close
()
throws
IOException
{
public
void
close
()
throws
IOException
{
controlConnection
.
delOnion
(
localOnion
);
controlConnection
.
delOnion
(
localOnion
);
tryToClose
(
ss
);
tryToClose
(
ss
,
LOG
,
WARNING
);
}
}
};
};
}
catch
(
IOException
e
)
{
}
catch
(
IOException
e
)
{
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment