Skip to content

Commit 4770091

Browse files
committed
Something
0 parents  commit 4770091

File tree

23 files changed

+1023
-0
lines changed

23 files changed

+1023
-0
lines changed

LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2016 Dusty Wilson
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

gabber/gabber.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
package gabber

gabby/compile.sh

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
#!/bin/bash
2+
3+
protoc -I . gabby.proto --go_out=plugins=grpc:.

gabby/gabby.pb.go

Lines changed: 227 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

gabby/gabby.proto

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
syntax = "proto3";
2+
3+
package gabby;
4+
5+
service Server {
6+
rpc Bye() returns () {}
7+
rpc Auth(AuthRequest) returns (AuthResponse) {}
8+
}
9+
10+
message AuthRequest {
11+
string id = 1;
12+
string secret = 2;
13+
}
14+
15+
message AuthResponse {
16+
enum Status {
17+
UNKNOWN = 0; // this response is probably invalid
18+
SUCCESS = 1; // success!
19+
BADAUTH = 2; // failed to authenticate due to incorrect credentials provided
20+
REDIRECTION = 3; // redirecting the client to a different server
21+
RETRYSOON = 4; // temporarily failed; try again after the specified delay interval
22+
SERVERQUIT = 5; // the server is quitting (temporarily or not) and no redirection was given; it'll be up to the client to figure out what to do with this status
23+
}
24+
Status status = 1;
25+
string redirect_to = 31;
26+
int32 retry_delay = 41;
27+
}

server/server.go

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
package server
2+
3+
import (
4+
"log"
5+
"net"
6+
7+
"go.gabby.network/api/gabby"
8+
"golang.org/x/net/context"
9+
"google.golang.org/grpc"
10+
)
11+
12+
// Server is a Gabby server, which handles the endpoints and authorization
13+
type Server struct{}
14+
15+
// New returns a new Server
16+
func New() *Server {
17+
return &Server{}
18+
}
19+
20+
// ListenAndServe runs the server loop
21+
func (s Server) ListenAndServe(addr string) {
22+
conn, err := net.Listen("tcp", addr)
23+
if err != nil {
24+
log.Fatalf("listen failure: %v", err)
25+
}
26+
g := grpc.NewServer()
27+
gabby.RegisterServerServer(g, s)
28+
if err := g.Serve(conn); err != nil {
29+
log.Fatalf("serve failure: %v", err)
30+
}
31+
}
32+
33+
// Auth handles the gRPC request for Auth
34+
func (s Server) Auth(c context.Context, r *gabby.AuthRequest) (*gabby.AuthResponse, error) {
35+
return nil, nil
36+
}

yyold/dns/txt.go

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
package dns
2+
3+
import (
4+
"strings"
5+
"time"
6+
7+
"github.com/dustywilson/httpdig"
8+
)
9+
10+
// TXT is a DNS TXT RR
11+
type TXT struct {
12+
TTL time.Duration
13+
Value string
14+
}
15+
16+
// LookupTXT looks up a TXT RR
17+
func LookupTXT(name string) ([]TXT, error) {
18+
r, err := httpdig.Query(name, "TXT")
19+
if err != nil {
20+
return nil, err
21+
}
22+
txts := make([]TXT, len(r.Answer))
23+
for i, a := range r.Answer {
24+
txts[i] = TXT{
25+
TTL: a.TTL,
26+
Value: strings.TrimPrefix(strings.TrimSuffix(a.Data, `"`), `"`),
27+
}
28+
}
29+
return txts, nil
30+
}

yyold/domain/domain.go

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
package domain
2+
3+
// Domain is a Gabby domain, which happens to map to DNS.
4+
type Domain struct {
5+
name string
6+
}
7+
8+
// String is the string representation of the domain itself (the domain name).
9+
func (d *Domain) String() string {
10+
return d.name
11+
}
12+
13+
// New returns a new Gabby domain
14+
func New(name string) (*Domain, error) {
15+
return &Domain{
16+
name: name,
17+
}, nil
18+
}

0 commit comments

Comments
 (0)