Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create Tools App #169

Merged
merged 7 commits into from
Jan 24, 2024
Merged
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
5 changes: 5 additions & 0 deletions x/examples/fyne-tools/FyneApp.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
[Details]
Icon = "Icon.png"
Name = "Net Tools"
ID = "org.getoutline.sdk.examples.fyne_tools"
Build = 9
Binary file added x/examples/fyne-tools/Icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
21 changes: 21 additions & 0 deletions x/examples/fyne-tools/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# DNS System Resolver Lookup Utility

To run:

```console
go run github.com/Jigsaw-Code/outline-sdk/x/examples/fyne-tools@latest
```

Package for Android and install on emulator or device:
```
go run fyne.io/fyne/v2/cmd/fyne package -os android && adb install Net_Tools.apk
```

Note: the generated APK is around 85MB.


## Screenshots

<img width="400" alt="image" src="https://github.com/Jigsaw-Code/outline-sdk/assets/113565/8cead9da-461e-41c8-8ce3-f263d77c6ee8">

<img width="462" alt="image" src="https://github.com/Jigsaw-Code/outline-sdk/assets/113565/9782eab3-d142-4be7-9431-5384c866384d">
26 changes: 26 additions & 0 deletions x/examples/fyne-tools/cname_desktop.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
// Copyright 2024 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
//
// https://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 !(android || ios)

package main

import (
"context"
"net"
)

func lookupCNAME(ctx context.Context, domain string) (string, error) {
return net.DefaultResolver.LookupCNAME(ctx, domain)
}
73 changes: 73 additions & 0 deletions x/examples/fyne-tools/cname_mobile.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
// Copyright 2024 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
//
// https://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 android || ios

package main

/*
#include <stdlib.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <netdb.h>
*/
import "C"

import (
"context"
"fmt"
"unsafe"
)

func lookupCNAME(ctx context.Context, domain string) (string, error) {
type result struct {
cname string
err error
}

results := make(chan result)
go func() {
cname, err := lookupCNAMEBlocking(domain)
results <- result{cname, err}
}()

select {
case r := <-results:
return r.cname, r.err
case <-ctx.Done():
return "", ctx.Err()
}
}

func lookupCNAMEBlocking(host string) (string, error) {
var hints C.struct_addrinfo
var result *C.struct_addrinfo

chost := C.CString(host)
defer C.free(unsafe.Pointer(chost))

hints.ai_family = C.AF_UNSPEC
hints.ai_flags = C.AI_CANONNAME

// Call getaddrinfo
res := C.getaddrinfo(chost, nil, &hints, &result)
if res != 0 {
return "", fmt.Errorf("getaddrinfo error: %s", C.GoString(C.gai_strerror(res)))
}
defer C.freeaddrinfo(result)

// Extract canonical name
cname := C.GoString(result.ai_canonname)
return cname, nil
}
59 changes: 59 additions & 0 deletions x/examples/fyne-tools/go.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
module github.com/Jigsaw-Code/outline-sdk/x/examples/fyne-tools

go 1.20

require (
fyne.io/fyne/v2 v2.4.3
github.com/Jigsaw-Code/outline-sdk v0.0.12
github.com/Jigsaw-Code/outline-sdk/x v0.0.0-20240117212231-233d1898e1db
)

require (
fyne.io/systray v1.10.1-0.20231115130155-104f5ef7839e // indirect
github.com/BurntSushi/toml v1.3.2 // indirect
github.com/akavel/rsrc v0.10.2 // indirect
github.com/cpuguy83/go-md2man/v2 v2.0.2 // indirect
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/fogleman/gg v1.3.0 // indirect
github.com/fredbi/uri v1.0.0 // indirect
github.com/fsnotify/fsnotify v1.6.0 // indirect
github.com/fyne-io/gl-js v0.0.0-20220119005834-d2da28d9ccfe // indirect
github.com/fyne-io/glfw-js v0.0.0-20220120001248-ee7290d23504 // indirect
github.com/fyne-io/image v0.0.0-20220602074514-4956b0afb3d2 // indirect
github.com/go-gl/gl v0.0.0-20211210172815-726fda9656d6 // indirect
github.com/go-gl/glfw/v3.3/glfw v0.0.0-20221017161538-93cebf72946b // indirect
github.com/go-ole/go-ole v1.2.6 // indirect
github.com/go-text/render v0.0.0-20230619120952-35bccb6164b8 // indirect
github.com/go-text/typesetting v0.0.0-20230616162802-9c17dd34aa4a // indirect
github.com/godbus/dbus/v5 v5.1.0 // indirect
github.com/golang/freetype v0.0.0-20170609003504-e2365dfdc4a0 // indirect
github.com/gopherjs/gopherjs v1.17.2 // indirect
github.com/jackmordaunt/icns/v2 v2.2.6 // indirect
github.com/josephspurrier/goversioninfo v1.4.0 // indirect
github.com/jsummers/gobmp v0.0.0-20151104160322-e2ba15ffa76e // indirect
github.com/lucor/goinfo v0.9.0 // indirect
github.com/mcuadros/go-version v0.0.0-20190830083331-035f6764e8d2 // indirect
github.com/nfnt/resize v0.0.0-20180221191011-83c6a9932646 // indirect
github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
github.com/russross/blackfriday/v2 v2.1.0 // indirect
github.com/shadowsocks/go-shadowsocks2 v0.1.5 // indirect
github.com/srwiley/oksvg v0.0.0-20221011165216-be6e8873101c // indirect
github.com/srwiley/rasterx v0.0.0-20220730225603-2ab79fcdd4ef // indirect
github.com/stretchr/testify v1.8.4 // indirect
github.com/tevino/abool v1.2.0 // indirect
github.com/urfave/cli/v2 v2.11.1 // indirect
github.com/xrash/smetrics v0.0.0-20201216005158-039620a65673 // indirect
github.com/yuin/goldmark v1.5.5 // indirect
golang.org/x/crypto v0.17.0 // indirect
golang.org/x/image v0.14.0 // indirect
golang.org/x/mobile v0.0.0-20231127183840-76ac6878050a // indirect
golang.org/x/mod v0.14.0 // indirect
golang.org/x/net v0.19.0 // indirect
golang.org/x/sys v0.15.0 // indirect
golang.org/x/text v0.14.0 // indirect
golang.org/x/tools v0.16.0 // indirect
gopkg.in/check.v1 v1.0.0-20200227125254-8fa46927fb4f // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
honnef.co/go/js/dom v0.0.0-20210725211120-f030747120f2 // indirect
)
Loading