Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions Android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,10 @@ def goSourcePackages = ["${goSourceDir}/backend",
"${goSourceDir}/intra/split",
"${goSourceDir}/intra/protect"]
def goBuildDir = file("${buildDir}/go")
def goExecutableSuffix = System.getProperty('os.name').toLowerCase().contains('windows') ?
'.exe' : ''
def goMobileExecutable = file("${goBuildDir}/gomobile${goExecutableSuffix}")
def goBindExecutable = file("${goBuildDir}/gobind${goExecutableSuffix}")
def goBackendAAR = file("${goBuildDir}/backend.aar")

// gomobile won't use the Go version in go.mod. So we need to manually read it from go.mod and
Expand Down Expand Up @@ -156,7 +160,7 @@ tasks.register('compileGoBackend', Exec) {
System.getProperty('path.separator') +
System.getenv('PATH')

commandLine("${goBuildDir}/gomobile", 'bind',
commandLine(goMobileExecutable, 'bind',
'-ldflags=-s -w',
'-target=android',
"-androidapi=${android.defaultConfig.minSdk}",
Expand All @@ -166,8 +170,8 @@ tasks.register('compileGoBackend', Exec) {

tasks.register('ensureGoMobile', Exec) {
// install gomobile and gobind into the build folder
outputs.file("${goBuildDir}/gomobile")
outputs.file("${goBuildDir}/gobind")
outputs.file(goMobileExecutable)
outputs.file(goBindExecutable)

doFirst { goBuildDir.mkdirs() }

Expand Down
27 changes: 12 additions & 15 deletions Android/app/src/go/backend/doh.go
Original file line number Diff line number Diff line change
Expand Up @@ -104,16 +104,13 @@ type DoHListener interface {
OnResponse(DoHQueryToken, *DoHQuerySumary)
}

// DoHStatus is an integer representing the status of a DoH transaction.
type DoHStatus = int

const (
DoHStatusComplete DoHStatus = doh.Complete // Transaction completed successfully
DoHStatusSendFailed DoHStatus = doh.SendFailed // Failed to send query
DoHStatusHTTPError DoHStatus = doh.HTTPError // Got a non-200 HTTP status
DoHStatusBadQuery DoHStatus = doh.BadQuery // Malformed input
DoHStatusBadResponse DoHStatus = doh.BadResponse // Response was invalid
DoHStatusInternalError DoHStatus = doh.InternalError // This should never happen
DoHStatusComplete = doh.Complete // Transaction completed successfully
DoHStatusSendFailed = doh.SendFailed // Failed to send query
DoHStatusHTTPError = doh.HTTPError // Got a non-200 HTTP status
DoHStatusBadQuery = doh.BadQuery // Malformed input
DoHStatusBadResponse = doh.BadResponse // Response was invalid
DoHStatusInternalError = doh.InternalError // This should never happen
)

// DoHQuerySumary is the summary of a DNS transaction.
Expand All @@ -122,12 +119,12 @@ type DoHQuerySumary struct {
summ *doh.Summary
}

func (q DoHQuerySumary) GetQuery() []byte { return q.summ.Query }
func (q DoHQuerySumary) GetResponse() []byte { return q.summ.Response }
func (q DoHQuerySumary) GetServer() string { return q.summ.Server }
func (q DoHQuerySumary) GetStatus() DoHStatus { return q.summ.Status }
func (q DoHQuerySumary) GetHTTPStatus() int { return q.summ.HTTPStatus }
func (q DoHQuerySumary) GetLatency() float64 { return q.summ.Latency }
func (q DoHQuerySumary) GetQuery() []byte { return q.summ.Query }
func (q DoHQuerySumary) GetResponse() []byte { return q.summ.Response }
func (q DoHQuerySumary) GetServer() string { return q.summ.Server }
func (q DoHQuerySumary) GetStatus() int { return q.summ.Status }
func (q DoHQuerySumary) GetHTTPStatus() int { return q.summ.HTTPStatus }
func (q DoHQuerySumary) GetLatency() float64 { return q.summ.Latency }

// dohListenerAdapter is an adapter for the internal [doh.Listener].
type dohListenerAdapter struct {
Expand Down
32 changes: 32 additions & 0 deletions Android/app/src/go/intra/engine.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
// Copyright 2026 Jigsaw Operations LLC
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

package intra

import (
"context"

"localhost/Intra/Android/app/src/go/logging"

"github.com/Jigsaw-Code/outline-sdk/network"
)

func newTunnelEngine(ctx context.Context, sd *intraStreamDialer, pp *intraPacketProxy) (network.IPDevice, error) {
if useXJasonlyuEngine {
logging.Debug("Intra tunnel engine selected", "engine", "xjasonlyu")
return newXJasonlyuEngine(ctx, sd, pp)
}
logging.Debug("Intra tunnel engine selected", "engine", "lwip")
return newLWIPTunnelEngine(sd, pp)
}
19 changes: 19 additions & 0 deletions Android/app/src/go/intra/engine_default.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
// Copyright 2026 Jigsaw Operations LLC
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

//go:build !xjasonlyu_experiment

package intra

const useXJasonlyuEngine = false
24 changes: 24 additions & 0 deletions Android/app/src/go/intra/engine_lwip.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
// Copyright 2026 Jigsaw Operations LLC
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

package intra

import (
"github.com/Jigsaw-Code/outline-sdk/network"
"github.com/Jigsaw-Code/outline-sdk/network/lwip2transport"
)

func newLWIPTunnelEngine(sd *intraStreamDialer, pp *intraPacketProxy) (network.IPDevice, error) {
return lwip2transport.ConfigureDevice(sd, pp)
}
Loading