Skip to content

Commit 0c74692

Browse files
committed
cleaned changes
1 parent b3cdf51 commit 0c74692

File tree

7 files changed

+40
-104
lines changed

7 files changed

+40
-104
lines changed

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ require (
1010
github.com/getlantern/systray v1.1.0
1111
github.com/miekg/dns v1.1.43
1212
github.com/pkg/browser v0.0.0-20210706143420-7d21f8c997e2
13-
github.com/randomlogin/sane v0.0.2
1413
github.com/spf13/viper v1.8.1
1514
github.com/sqweek/dialog v0.0.0-20210702151303-c326b49d3f01
1615
golang.org/x/crypto v0.16.0
@@ -276,6 +275,7 @@ require (
276275
github.com/prometheus/common v0.6.0 // indirect
277276
github.com/prometheus/procfs v0.0.2 // indirect
278277
github.com/prometheus/tsdb v0.7.1 // indirect
278+
github.com/randomlogin/sane v0.0.3-0.20240214015449-25817feea1bb // indirect
279279
github.com/retailnext/hllpp v1.0.1-0.20180308014038-101a6d2f8b52 // indirect
280280
github.com/rjeczalik/notify v0.9.1 // indirect
281281
github.com/rogpeppe/fastuuid v1.2.0 // indirect

go.sum

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -468,6 +468,8 @@ github.com/prometheus/tsdb v0.7.1 h1:YZcsG11NqnK4czYLrWd9mpEuAJIHVQLwdrleYfszMAA
468468
github.com/prometheus/tsdb v0.7.1/go.mod h1:qhTCs0VvXwvX/y3TZrWD7rabWM+ijKTux40TwIPHuXU=
469469
github.com/randomlogin/sane v0.0.2 h1:rWnVhAOJt8h4dyyCNI4AQdEUPrl7JWoo0dsg82/IFgk=
470470
github.com/randomlogin/sane v0.0.2/go.mod h1:HPQHPiYP6lIs+7yjaJVnohnv5kHHif7lrsWp/JVUFcc=
471+
github.com/randomlogin/sane v0.0.3-0.20240214015449-25817feea1bb h1:PJTU2XOK9mpJeckmYYctf9AKqp4gfmljmfgmJgdfVe8=
472+
github.com/randomlogin/sane v0.0.3-0.20240214015449-25817feea1bb/go.mod h1:HPQHPiYP6lIs+7yjaJVnohnv5kHHif7lrsWp/JVUFcc=
471473
github.com/retailnext/hllpp v1.0.1-0.20180308014038-101a6d2f8b52/go.mod h1:RDpi1RftBQPUCDRw6SmxeaREsAaRKnOclghuzp/WRzc=
472474
github.com/rjeczalik/notify v0.9.1 h1:CLCKso/QK1snAlnhNR/CNvNiFU2saUtjV0bx3EwNeCE=
473475
github.com/rjeczalik/notify v0.9.1/go.mod h1:rKwnCoCGeuQnwBtTSPL9Dad03Vh2n40ePRrjvIXnJho=

internal/config/auto/install.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ import (
77
"errors"
88
"fmt"
99
"io/fs"
10-
"io/ioutil"
1110
"os"
1211
"path"
1312
"strings"
@@ -134,7 +133,7 @@ func getProfilePaths() ([]string, error) {
134133
}
135134

136135
func readPEM(certPath string) ([]byte, error) {
137-
cert, err := ioutil.ReadFile(certPath)
136+
cert, err := os.ReadFile(certPath)
138137
if err != nil {
139138
return nil, fmt.Errorf("failed reading root certificate: %v", err)
140139
}

internal/config/config.go

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,13 @@ import (
77
"encoding/json"
88
"encoding/pem"
99
"fmt"
10-
"github.com/randomlogin/sane"
11-
"io/ioutil"
1210
"net/http"
1311
"os"
1412
"path"
1513
"strings"
1614
"time"
15+
16+
"github.com/randomlogin/sane"
1717
)
1818

1919
const AppName = "Fingertip"
@@ -23,13 +23,13 @@ const CertKeyFileName = "private.key"
2323
const CertName = "DNSSEC"
2424

2525
type App struct {
26-
Path string
27-
CertPath string
28-
keyPath string
26+
Path string
27+
CertPath string
28+
keyPath string
2929
// DNSProcPath string
30-
Proxy sane.Config
31-
ProxyAddr string
32-
Version string
30+
Proxy sane.Config
31+
ProxyAddr string
32+
Version string
3333

3434
Store *Store
3535
Debug Debugger
@@ -93,12 +93,12 @@ func (c *App) getOrCreateCA() (string, string, error) {
9393
}
9494

9595
func loadX509KeyPair(certFile, keyFile string) (tls.Certificate, error) {
96-
certPEMBlock, err := ioutil.ReadFile(certFile)
96+
certPEMBlock, err := os.ReadFile(certFile)
9797
if err != nil {
9898
return tls.Certificate{}, err
9999
}
100100

101-
keyPEMBlock, err := ioutil.ReadFile(keyFile)
101+
keyPEMBlock, err := os.ReadFile(keyFile)
102102
if err != nil {
103103
return tls.Certificate{}, err
104104
}
@@ -175,10 +175,10 @@ func NewConfig() (*App, error) {
175175

176176
c.Proxy.Constraints = nameConstraints
177177
c.Proxy.SkipNameChecks = false
178-
c.Proxy.Verbose = false
179178
c.Proxy.Validity = time.Hour
180179
c.Proxy.ContentHandler = &contentHandler{c}
181-
c.Proxy.Verbose = true
180+
c.Proxy.Verbose = false
181+
c.Proxy.ExternalService = DefaultExternalService
182182
c.Proxy.RootsPath = path.Join(c.Path, "roots.json")
183183
if c.Proxy.Certificate, c.Proxy.PrivateKey, err = c.loadCA(); err != nil {
184184
return nil, fmt.Errorf("failed creating config: %v", err)

internal/config/user.go

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,17 @@ import (
44
"encoding/json"
55
"errors"
66
"fmt"
7-
"github.com/spf13/viper"
8-
"io/ioutil"
97
"os"
8+
9+
"github.com/spf13/viper"
1010
)
1111

1212
const (
1313
DefaultProxyAddr = "127.0.0.1:9590"
1414
DefaultRootAddr = "127.0.0.1:9591"
15-
DefaultRecursiveAddr = "127.0.0.1:9592"
15+
DefaultRecursiveAddr = "https://hnsdoh.com/dns-query"
1616
DefaultEthereumEndpoint = "https://mainnet.infura.io/v3/b0933ce6026a4e1e80e89e96a5d095bc"
17+
DefaultExternalService = "https://sdaneproofs.htools.work/proofs/"
1718
)
1819

1920
// User Represents user facing configuration
@@ -47,7 +48,7 @@ func readStore(path, version string, old *Store) (*Store, error) {
4748
return zero, nil
4849
}
4950

50-
b, err := ioutil.ReadFile(path)
51+
b, err := os.ReadFile(path)
5152
if err != nil {
5253
return nil, fmt.Errorf("failed reading app config: %v", err)
5354
}
@@ -71,7 +72,7 @@ func (i *Store) Save() error {
7172
return fmt.Errorf("failed encoding app config: %v", err)
7273
}
7374

74-
if err := ioutil.WriteFile(i.path, b, 0664); err != nil {
75+
if err := os.WriteFile(i.path, b, 0664); err != nil {
7576
return fmt.Errorf("faild writing app config: %v", err)
7677
}
7778
return err
@@ -91,6 +92,7 @@ func ReadUserConfig(path string) (config User, err error) {
9192
viper.SetDefault("PROXY_ADDRESS", DefaultProxyAddr)
9293
viper.SetDefault("ROOT_ADDRESS", DefaultRootAddr)
9394
viper.SetDefault("RECURSIVE_ADDRESS", DefaultRecursiveAddr)
95+
viper.SetDefault("EXTERNAL_SERVICE", DefaultExternalService)
9496
viper.SetDefault("ETHEREUM_ENDPOINT", DefaultEthereumEndpoint)
9597

9698
err = viper.ReadInConfig()

internal/resolvers/dnssec/dnssec_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,15 @@ package dnssec
33
import (
44
"bufio"
55
"errors"
6-
"github.com/miekg/dns"
7-
"io/ioutil"
86
"os"
97
"path"
108
"sort"
119
"strconv"
1210
"strings"
1311
"testing"
1412
"time"
13+
14+
"github.com/miekg/dns"
1515
)
1616

1717
type testHDR struct {
@@ -36,7 +36,7 @@ func TestVerify(t *testing.T) {
3636
wd, _ := os.Getwd()
3737

3838
dir := path.Join(wd, "testdata")
39-
files, err := ioutil.ReadDir(dir)
39+
files, err := os.ReadDir(dir)
4040
if err != nil {
4141
t.Fatal(err)
4242
}

main.go

Lines changed: 14 additions & 81 deletions
Original file line numberDiff line numberDiff line change
@@ -5,20 +5,22 @@ import (
55
"fingertip/internal/config"
66
"fingertip/internal/config/auto"
77
"fingertip/internal/resolvers"
8+
89
// "fingertip/internal/resolvers/proc"
910
"fingertip/internal/ui"
1011
"fmt"
11-
"github.com/randomlogin/sane"
12-
"github.com/randomlogin/sane/resolver"
13-
"github.com/randomlogin/sane/sync"
14-
"github.com/emersion/go-autostart"
15-
"github.com/pkg/browser"
1612
"log"
1713
"net/http"
1814
"os"
1915
"path"
2016
"path/filepath"
2117
"time"
18+
19+
"github.com/emersion/go-autostart"
20+
"github.com/pkg/browser"
21+
"github.com/randomlogin/sane"
22+
"github.com/randomlogin/sane/resolver"
23+
"github.com/randomlogin/sane/sync"
2224
)
2325

2426
const Version = "0.0.3"
@@ -47,11 +49,6 @@ func setupApp() *App {
4749

4850
c.Version = Version
4951

50-
// c.DNSProcPath, err = getProcPath()
51-
// if err != nil {
52-
// log.Fatal(err)
53-
// }
54-
// c.DNSProcPath = path.Join(c.DNSProcPath, "hnsd")
5552
app, err := NewApp(c)
5653
if err != nil {
5754
log.Fatal(err)
@@ -149,14 +146,16 @@ func main() {
149146
app.autostartEnabled = true
150147
}
151148

152-
// hnsErrCh := make(chan error)
153149
serverErrCh := make(chan error)
154150
onBoardingFilename := path.Join(app.config.Path, "init")
155151
onBoarded := onBoardingSeen(onBoardingFilename)
156152

153+
hnsdPath, err := getProcPath()
154+
if err != nil {
155+
log.Fatal(err)
156+
}
157+
hnsdPath = path.Join(hnsdPath, "/hnsd")
157158

158-
// TODO: this should probably move into start() below?
159-
hnsdPath := "/media/data/Projects/handshake/hnsd/hnsd"
160159
hnsdCheckpointPath := ""
161160
if hnsdPath == "" {
162161
log.Fatal("path to hnsd is not provided")
@@ -169,7 +168,6 @@ func main() {
169168
sync.GetRoots(hnsdPath, app.config.Path, hnsdCheckpointPath)
170169

171170
start := func() {
172-
// app.proc.Start(hnsErrCh)
173171
ui.Data.SetOptionsEnabled(true)
174172
ui.Data.SetStarted(true)
175173

@@ -222,62 +220,6 @@ func main() {
222220
return true
223221
}
224222

225-
// ticker := time.NewTicker(150 * time.Millisecond)
226-
227-
// go func() {
228-
// for {
229-
// select {
230-
// case err := <-serverErrCh:
231-
// if errors.Is(err, http.ErrServerClosed) {
232-
// continue
233-
// }
234-
235-
// ui.ShowErrorDlg(err.Error())
236-
// log.Printf("[ERR] app: proxy server failed: %v", err)
237-
238-
// app.stop()
239-
// ui.Data.SetStarted(false)
240-
// case err := <-hnsErrCh:
241-
// if !app.proc.Started() {
242-
// continue
243-
// }
244-
245-
// // hns process crashed attempt to restart
246-
// // TODO: check if port is already in use
247-
248-
// attempts := app.proc.Retries()
249-
// if attempts > 9 {
250-
// err := fmt.Errorf("[ERR] app: fatal error hnsd process keeps crashing err: %v", err)
251-
// ui.ShowErrorDlg(err.Error())
252-
// app.stop()
253-
// log.Fatal(err)
254-
// }
255-
256-
// // log to a file could be useful for debugging
257-
// line := fmt.Sprintf("[ERR] app: hnsd process crashed restart attempt #%d err: %v", attempts, err)
258-
// log.Printf(line)
259-
// fileLogger.Printf(line)
260-
261-
// // increment retries and restart process
262-
// app.proc.IncrementRetries()
263-
// app.proc.Stop()
264-
// app.proc.Start(hnsErrCh)
265-
266-
// case <-ticker.C:
267-
// if !app.proc.Started() {
268-
// ui.Data.SetBlockHeight("--")
269-
// app.config.Debug.SetBlockHeight(0)
270-
// continue
271-
// }
272-
273-
// height := app.proc.GetHeight()
274-
// ui.Data.SetBlockHeight(fmt.Sprintf("#%d", height))
275-
// app.config.Debug.SetBlockHeight(height)
276-
// }
277-
278-
// }
279-
// }()
280-
281223
ui.OnStop = func() {
282224
app.stop()
283225
ui.Data.SetOptionsEnabled(false)
@@ -314,7 +256,6 @@ func main() {
314256

315257
func NewApp(appConfig *config.App) (*App, error) {
316258
var err error
317-
// var hnsProc *proc.HNSProc
318259
app := &App{
319260
autostart: &autostart.App{
320261
Name: config.AppId,
@@ -332,13 +273,6 @@ func NewApp(appConfig *config.App) (*App, error) {
332273
app.proxyURL = config.GetProxyURL(usrConfig.ProxyAddr)
333274
app.usrConfig = &usrConfig
334275

335-
// if hnsProc, err = proc.NewHNSProc(appConfig.DNSProcPath, usrConfig.RootAddr, usrConfig.RecursiveAddr); err != nil {
336-
// return nil, err
337-
// }
338-
// hnsProc.SetUserAgent("fingertip:" + Version)
339-
340-
// app.proc = hnsProc
341-
342276
app.server, err = app.newProxyServer()
343277
if err != nil {
344278
return nil, err
@@ -348,13 +282,12 @@ func NewApp(appConfig *config.App) (*App, error) {
348282
}
349283

350284
func (a *App) NewResolver() (resolver.Resolver, error) {
351-
// rs, err := resolver.NewStub(a.usrConfig.RecursiveAddr)
352-
rs, err := resolver.NewStub("https://hnsdoh.com/dns-query")
285+
rs, err := resolver.NewStub(a.usrConfig.RecursiveAddr)
353286
if err != nil {
354287
return nil, err
355288
}
356289

357-
hip5 := resolvers.NewHIP5Resolver(rs, a.usrConfig.RootAddr, func() bool {return true})
290+
hip5 := resolvers.NewHIP5Resolver(rs, a.usrConfig.RootAddr, func() bool { return true })
358291
ethExt, err := resolvers.NewEthereum(a.usrConfig.EthereumEndpoint)
359292
if err != nil {
360293
return nil, err

0 commit comments

Comments
 (0)