Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
hotspot
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Analyze
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
hotspot
Commits
8acf8f14
Verified
Commit
8acf8f14
authored
4 years ago
by
Torsten Grote
Browse files
Options
Downloads
Patches
Plain Diff
Use actual IPv4 address from p2p interface
parent
3e3173e1
No related branches found
Branches containing commit
No related tags found
1 merge request
!2
Add fragment for network interfaces und use address if p2p interface, if available
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
app/src/main/java/org/briarproject/hotspot/NetworkUtils.java
+15
-0
15 additions, 0 deletions
app/src/main/java/org/briarproject/hotspot/NetworkUtils.java
app/src/main/java/org/briarproject/hotspot/ServerFragment.java
+13
-0
13 additions, 0 deletions
...rc/main/java/org/briarproject/hotspot/ServerFragment.java
with
28 additions
and
0 deletions
app/src/main/java/org/briarproject/hotspot/NetworkUtils.java
+
15
−
0
View file @
8acf8f14
package
org.briarproject.hotspot
;
import
androidx.annotation.Nullable
;
import
java.net.InetAddress
;
import
java.net.InterfaceAddress
;
import
java.net.NetworkInterface
;
import
java.net.SocketException
;
...
...
@@ -12,6 +15,18 @@ import static java.util.Collections.list;
class
NetworkUtils
{
@Nullable
static
InetAddress
getAccessPointAddress
()
{
for
(
NetworkInterface
i:
getNetworkInterfaces
())
{
if
(
i
.
getName
().
startsWith
(
"p2p"
))
{
for
(
InterfaceAddress
a
:
i
.
getInterfaceAddresses
())
{
if
(
a
.
getAddress
().
getAddress
().
length
==
4
)
return
a
.
getAddress
();
}
}
}
return
null
;
}
static
String
getNetworkInterfaceSummary
()
{
StringBuilder
sb
=
new
StringBuilder
();
for
(
NetworkInterface
i:
getNetworkInterfaces
())
{
...
...
This diff is collapsed.
Click to expand it.
app/src/main/java/org/briarproject/hotspot/ServerFragment.java
+
13
−
0
View file @
8acf8f14
...
...
@@ -2,6 +2,7 @@ package org.briarproject.hotspot;
import
android.graphics.Bitmap
;
import
android.os.Bundle
;
import
android.util.Log
;
import
android.view.LayoutInflater
;
import
android.view.Menu
;
import
android.view.MenuInflater
;
...
...
@@ -15,12 +16,17 @@ import androidx.annotation.NonNull;
import
androidx.annotation.Nullable
;
import
androidx.fragment.app.Fragment
;
import
java.net.InetAddress
;
import
static
android
.
view
.
View
.
GONE
;
import
static
android
.
view
.
View
.
VISIBLE
;
import
static
org
.
briarproject
.
hotspot
.
NetworkUtils
.
getAccessPointAddress
;
import
static
org
.
briarproject
.
hotspot
.
QrCodeUtils
.
createQrCode
;
public
class
ServerFragment
extends
Fragment
{
private
static
String
TAG
=
ServerFragment
.
class
.
getName
();
@Override
public
View
onCreateView
(
LayoutInflater
inflater
,
ViewGroup
container
,
Bundle
savedInstanceState
)
{
...
...
@@ -36,6 +42,13 @@ public class ServerFragment extends Fragment {
TextView
urlView
=
v
.
findViewById
(
R
.
id
.
url
);
String
text
=
"http://192.168.49.1:9999"
;
InetAddress
address
=
getAccessPointAddress
();
if
(
address
==
null
)
{
Log
.
i
(
TAG
,
"Could not find access point address, assuming 192.168.49.1"
);
}
else
{
Log
.
i
(
TAG
,
"Access point address "
+
address
.
getHostAddress
());
text
=
"http://"
+
address
.
getHostAddress
()
+
":9999"
;
}
Bitmap
qrCodeBitmap
=
createQrCode
(
getResources
().
getDisplayMetrics
(),
text
);
if
(
qrCodeBitmap
==
null
)
{
...
...
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