Skip to content

Commit

Permalink
remove duplicate of tls-setup; clean up;
Browse files Browse the repository at this point in the history
Ready for next separation of server_info.go
Verification procedures of Certs and PKIs shall be as dynamic as possible
Complex metrics and time based tasks will be added
  • Loading branch information
AZ-X committed Apr 12, 2021
1 parent a04fb98 commit 0e8e89a
Show file tree
Hide file tree
Showing 6 changed files with 119 additions and 98 deletions.
27 changes: 27 additions & 0 deletions repique/common/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,35 @@ type RegisteredServer struct {
/*--------------------------------------------------------------------------------------*/

//name, conn, err
type TLSContextDial func(ctx context.Context, network, addr string) (*string, net.Conn, error)

type TLSContext struct {
context.Context
TLSContextDial
}

func (c *TLSContext) Value(key interface{}) interface{} {
return c.TLSContextDial
}

//soul of HTTPS
type HTTPSContext struct {
*TLSContext
Tag *string //redundant key; for cm.key() & connectMethodKey mod
}

func (c *HTTPSContext) Value(key interface{}) interface{} {
if "Tag" == key {
return *c.Tag
}
return c.TLSContextDial
}

func (c *HTTPSContext) WithContext(inner context.Context) context.Context {
ctx := *c
ctx.Context = inner
return &ctx
}

type Endpoint struct {
Expand Down
2 changes: 1 addition & 1 deletion repique/configuration/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -491,7 +491,7 @@ func (config *Config) loadSource(proxy *dns.Proxy, requiredProps stamps.ServerIn
panic(err)
}
case proto == "DoT":
if err := proxy.XTransport.BuildTLS(registeredserver); err != nil {
if err := proxy.XTransport.BuildTLS(registeredserver, false); err != nil {
panic(err)
}
default:continue
Expand Down
6 changes: 6 additions & 0 deletions repique/features/dns/nodes/node_manager.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
package nodes

import (
)


6 changes: 3 additions & 3 deletions repique/features/dns/resort_proxy.go
Original file line number Diff line number Diff line change
Expand Up @@ -323,19 +323,19 @@ func (proxy *Proxy) ExchangeDnScRypt(serverInfo *DNSCryptInfo, request *[]byte)
return &bin, err
}

func (proxy *Proxy) doHQuery(name string, path string, useGet bool, ctx *tls.HTTPSContext, body *[]byte, cbs ...interface{}) ([]byte, error) {
func (proxy *Proxy) doHQuery(name string, path string, useGet bool, ctx context.Context, body *[]byte, cbs ...interface{}) ([]byte, error) {
if useGet {
return proxy.XTransport.FetchHTTPS(name, path, "GET", true, ctx, body, proxy.Timeout, cbs...)
}
return proxy.XTransport.FetchHTTPS(name, path, "POST", true, ctx, body, proxy.Timeout, cbs...)
}

func (proxy *Proxy) DoHQuery(name string, info *DOHInfo, ctx *tls.HTTPSContext, request *[]byte, cbs ...interface{}) (*[]byte, error) {
func (proxy *Proxy) DoHQuery(name string, info *DOHInfo, ctx context.Context, request *[]byte, cbs ...interface{}) (*[]byte, error) {
bin, err := proxy.doHQuery(name, info.Path, info.useGet, ctx, request, cbs...)
return &bin, err
}

func (proxy *Proxy) DoTQuery(name string, ctx *common.TLSContext, request *[]byte, cbs ...interface{}) (*[]byte, error) {
func (proxy *Proxy) DoTQuery(name string, ctx context.Context, request *[]byte, cbs ...interface{}) (*[]byte, error) {
bin, err := proxy.XTransport.FetchDoT(name, proxy.MainProto, ctx, request, proxy.Timeout, cbs...)
return &bin, err
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package dns
package extensions

//import (
// "github.com/AZ-X/dns"
Expand Down
Loading

0 comments on commit 0e8e89a

Please sign in to comment.