mirror of
https://github.com/boringproxy/boringproxy.git
synced 2025-02-25 18:55:29 -06:00
Move namdrop into separate library
This commit is contained in:
parent
988bb37bad
commit
42f0580690
@ -20,6 +20,8 @@ import (
|
|||||||
|
|
||||||
"github.com/caddyserver/certmagic"
|
"github.com/caddyserver/certmagic"
|
||||||
"github.com/mdp/qrterminal/v3"
|
"github.com/mdp/qrterminal/v3"
|
||||||
|
|
||||||
|
"github.com/takingnames/namedrop-go"
|
||||||
)
|
)
|
||||||
|
|
||||||
type Config struct {
|
type Config struct {
|
||||||
@ -42,11 +44,6 @@ type Server struct {
|
|||||||
httpListener *PassthroughListener
|
httpListener *PassthroughListener
|
||||||
}
|
}
|
||||||
|
|
||||||
type NamedropTokenData struct {
|
|
||||||
Owner string `json:"owner"`
|
|
||||||
Scope string `json:"scope"`
|
|
||||||
}
|
|
||||||
|
|
||||||
func checkPublicAddress(host string, port int) error {
|
func checkPublicAddress(host string, port int) error {
|
||||||
|
|
||||||
ln, err := net.Listen("tcp", fmt.Sprintf(":%d", port))
|
ln, err := net.Listen("tcp", fmt.Sprintf(":%d", port))
|
||||||
@ -291,16 +288,16 @@ func Listen() {
|
|||||||
|
|
||||||
accessToken := tok.AccessToken
|
accessToken := tok.AccessToken
|
||||||
|
|
||||||
resp, err := http.Get("https://takingnames.io/namedrop/token-data?access_token=" + accessToken)
|
tokenResp, err := http.Get("https://takingnames.io/namedrop/token-data?access_token=" + accessToken)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
w.WriteHeader(500)
|
w.WriteHeader(500)
|
||||||
io.WriteString(w, err.Error())
|
io.WriteString(w, err.Error())
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
defer resp.Body.Close()
|
defer tokenResp.Body.Close()
|
||||||
bodyJson, err := io.ReadAll(resp.Body)
|
bodyJson, err := io.ReadAll(tokenResp.Body)
|
||||||
|
|
||||||
var namedropTokenData NamedropTokenData
|
var namedropTokenData namedrop.TokenData
|
||||||
err = json.Unmarshal(bodyJson, &namedropTokenData)
|
err = json.Unmarshal(bodyJson, &namedropTokenData)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
w.WriteHeader(500)
|
w.WriteHeader(500)
|
||||||
|
3
go.mod
3
go.mod
@ -2,10 +2,13 @@ module github.com/boringproxy/boringproxy
|
|||||||
|
|
||||||
go 1.17
|
go 1.17
|
||||||
|
|
||||||
|
replace github.com/takingnames/namedrop-go => ../namedrop-go
|
||||||
|
|
||||||
require (
|
require (
|
||||||
github.com/caddyserver/certmagic v0.12.0
|
github.com/caddyserver/certmagic v0.12.0
|
||||||
github.com/mdp/qrterminal/v3 v3.0.0
|
github.com/mdp/qrterminal/v3 v3.0.0
|
||||||
github.com/skip2/go-qrcode v0.0.0-20200617195104-da1b6568686e
|
github.com/skip2/go-qrcode v0.0.0-20200617195104-da1b6568686e
|
||||||
|
github.com/takingnames/namedrop-go v0.0.0-00010101000000-000000000000
|
||||||
golang.org/x/crypto v0.0.0-20200728195943-123391ffb6de
|
golang.org/x/crypto v0.0.0-20200728195943-123391ffb6de
|
||||||
golang.org/x/oauth2 v0.0.0-20211104180415-d3ed0bb246c8
|
golang.org/x/oauth2 v0.0.0-20211104180415-d3ed0bb246c8
|
||||||
)
|
)
|
||||||
|
Loading…
Reference in New Issue
Block a user