Skip to content

Commit 8b766fe

Browse files
authored
Revert "feat: support connectivity check callback" (#137)
1 parent 95a77e5 commit 8b766fe

File tree

15 files changed

+71
-389
lines changed

15 files changed

+71
-389
lines changed

Diff for: cmd/run.go

+1-10
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ import (
2020
"github.com/daeuniverse/dae-wing/graphql"
2121
"github.com/daeuniverse/dae-wing/graphql/service/config"
2222
"github.com/daeuniverse/dae-wing/webrender"
23-
"github.com/daeuniverse/dae-wing/ws"
2423
"github.com/golang-jwt/jwt/v5"
2524
"github.com/graph-gophers/graphql-go/relay"
2625
"github.com/rs/cors"
@@ -119,7 +118,6 @@ var (
119118
}
120119
mux := http.NewServeMux()
121120
mux.Handle("/graphql", auth(cors.AllowAll().Handler(&relay.Handler{Schema: schema})))
122-
mux.Handle("/ws", auth(cors.AllowAll().Handler(&ws.Handler{})))
123121
if err = webrender.Handle(mux); err != nil {
124122
errorExit(err)
125123
}
@@ -211,11 +209,7 @@ func shouldReload() (ok bool, err error) {
211209

212210
func auth(next http.Handler) http.Handler {
213211
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
214-
authorization := r.Header.Get("Authorization")
215-
if authorization == "" {
216-
authorization = r.URL.Query().Get("authorization")
217-
}
218-
authorization = strings.TrimPrefix(authorization, "Bearer ")
212+
authorization := strings.TrimPrefix(r.Header.Get("Authorization"), "Bearer ")
219213
var user db.User
220214
token, err := jwt.Parse(authorization, func(token *jwt.Token) (interface{}, error) {
221215
// Don't forget to validate the alg is what you expect:
@@ -244,9 +238,6 @@ func auth(next http.Handler) http.Handler {
244238
ctx = context.WithValue(ctx, "user", &user)
245239
}
246240
}
247-
w.Header().Set("x-auth-result", "1")
248-
} else {
249-
w.Header().Set("x-auth-result", "0")
250241
}
251242
next.ServeHTTP(w, r.WithContext(ctx))
252243
})

Diff for: dae-core

Submodule dae-core updated 154 files

Diff for: dae/daemsg_producer.go

-66
This file was deleted.

Diff for: dae/run.go

+17-29
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,6 @@ var GracefullyExit = make(chan struct{})
3030
var EmptyConfig *daeConfig.Config
3131
var c *control.ControlPlane
3232
var onceWaitingNetwork sync.Once
33-
var ChMsg chan *control.Msg
34-
var MsgProducer *DaeMsgProducer
3533

3634
func init() {
3735
sections, err := config_parser.Parse(`global{} routing{}`)
@@ -45,11 +43,10 @@ func init() {
4543
}
4644

4745
func ControlPlane() (*control.ControlPlane, error) {
48-
ctl := c
49-
if ctl == nil {
46+
if c == nil {
5047
return nil, ErrControlPlaneNotInit
5148
}
52-
return ctl, nil
49+
return c, nil
5350
}
5451

5552
func Run(log *logrus.Logger, conf *daeConfig.Config, externGeoDataDirs []string, disableTimestamp bool, dry bool) (err error) {
@@ -70,10 +67,7 @@ func Run(log *logrus.Logger, conf *daeConfig.Config, externGeoDataDirs []string,
7067
}
7168

7269
// New c.
73-
ChMsg = make(chan *control.Msg, 10)
74-
MsgProducer = NewDaeMsgProducer(ChMsg)
75-
go MsgProducer.Run()
76-
c, err = newControlPlane(log, nil, nil, conf, externGeoDataDirs, ChMsg)
70+
c, err = newControlPlane(log, nil, nil, conf, externGeoDataDirs)
7771
if err != nil {
7872
return err
7973
}
@@ -150,10 +144,8 @@ loop:
150144
// Only keep dns cache when ip version preference not change.
151145
dnsCache = c.CloneDnsCache()
152146
}
153-
// New ChMsg.
154-
newChMsg := make(chan *control.Msg, 10)
155147
log.Warnln("[Reload] Load new control plane")
156-
newC, err := newControlPlane(log, obj, dnsCache, newConf, externGeoDataDirs, newChMsg)
148+
newC, err := newControlPlane(log, obj, dnsCache, newConf, externGeoDataDirs)
157149
if err != nil {
158150
/* dae-wing start */
159151
errReload = err
@@ -163,7 +155,7 @@ loop:
163155
"err": err,
164156
}).Errorln("[Reload] Failed to reload; try to roll back configuration")
165157
// Load last config back.
166-
newC, err = newControlPlane(log, obj, dnsCache, conf, externGeoDataDirs, ChMsg)
158+
newC, err = newControlPlane(log, obj, dnsCache, conf, externGeoDataDirs)
167159
if err != nil {
168160
obj.Close()
169161
c.Close()
@@ -172,7 +164,6 @@ loop:
172164
}).Fatalln("[Reload] Failed to roll back configuration")
173165
}
174166
newConf = conf
175-
newChMsg = ChMsg
176167
log.Errorln("[Reload] Last reload failed; rolled back configuration")
177168
} else {
178169
log.Warnln("[Reload] Stopped old control plane")
@@ -189,8 +180,6 @@ loop:
189180
oldC := c
190181
c = newC
191182
conf = newConf
192-
ChMsg = newChMsg
193-
MsgProducer.ReassignChMsg(newChMsg)
194183
reloading = true
195184
/* dae-wing start */
196185
chCallback = newReloadMsg.Callback
@@ -206,7 +195,7 @@ loop:
206195
return nil
207196
}
208197

209-
func newControlPlane(log *logrus.Logger, bpf interface{}, dnsCache map[string]*control.DnsCache, conf *daeConfig.Config, externGeoDataDirs []string, chMsg chan<- *control.Msg) (c *control.ControlPlane, err error) {
198+
func newControlPlane(log *logrus.Logger, bpf interface{}, dnsCache map[string]*control.DnsCache, conf *daeConfig.Config, externGeoDataDirs []string) (c *control.ControlPlane, err error) {
210199

211200
// Print configuration.
212201
if log.IsLevelEnabled(logrus.DebugLevel) {
@@ -240,18 +229,17 @@ func newControlPlane(log *logrus.Logger, bpf interface{}, dnsCache map[string]*c
240229
}
241230

242231
// New dae control plane.
243-
c, err = control.NewControlPlane(&control.Options{
244-
Log: log,
245-
Bpf: bpf,
246-
DnsCache: dnsCache,
247-
TagToNodeList: subscriptionToNodeList,
248-
Groups: conf.Group,
249-
RoutingA: &conf.Routing,
250-
Global: &conf.Global,
251-
DnsConfig: &conf.Dns,
252-
ExternGeoDataDirs: externGeoDataDirs,
253-
ChMsg: chMsg,
254-
})
232+
c, err = control.NewControlPlane(
233+
log,
234+
bpf,
235+
dnsCache,
236+
subscriptionToNodeList,
237+
conf.Group,
238+
&conf.Routing,
239+
&conf.Global,
240+
&conf.Dns,
241+
externGeoDataDirs,
242+
)
255243
if err != nil {
256244
return nil, err
257245
}

Diff for: go.mod

+3-8
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,13 @@
11
module github.com/daeuniverse/dae-wing
22

3-
go 1.21.0
4-
5-
toolchain go1.21.3
3+
go 1.19
64

75
require (
86
github.com/daeuniverse/dae v0.2.0
97
github.com/glebarez/sqlite v1.8.0
108
github.com/golang-jwt/jwt/v5 v5.0.0
119
github.com/graph-gophers/graphql-go v1.5.1-0.20230228210639-f05ace9f4a41
1210
github.com/json-iterator/go v1.1.12
13-
github.com/lesismal/nbio v1.3.20
1411
github.com/matoous/go-nanoid/v2 v2.0.0
1512
github.com/mohae/deepcopy v0.0.0-20170929034955-c48cc78d4826
1613
github.com/mzz2017/softwind v0.0.0-20230803152605-5f1f6bc06934
@@ -38,6 +35,7 @@ require (
3835
github.com/bits-and-blooms/bloom/v3 v3.5.0 // indirect
3936
github.com/cilium/ebpf v0.11.0 // indirect
4037
github.com/daeuniverse/dae-config-dist/go/dae_config v0.0.0-20230604120805-1c27619b592d // indirect
38+
github.com/daeuniverse/outbound v0.0.0-20240101085641-7932e7df927d // indirect
4139
github.com/daeuniverse/softwind v0.0.0-20231230065827-eed67f20d2c1 // indirect
4240
github.com/dgryski/go-camellia v0.0.0-20191119043421-69a8a13fb23d // indirect
4341
github.com/dgryski/go-idea v0.0.0-20170306091226-d2fb45a411fb // indirect
@@ -56,7 +54,6 @@ require (
5654
github.com/jinzhu/inflection v1.0.0 // indirect
5755
github.com/jinzhu/now v1.1.5 // indirect
5856
github.com/klauspost/compress v1.16.7 // indirect
59-
github.com/lesismal/llib v1.1.12 // indirect
6057
github.com/mattn/go-colorable v0.1.13 // indirect
6158
github.com/mattn/go-isatty v0.0.19 // indirect
6259
github.com/mattn/go-sqlite3 v1.14.17 // indirect
@@ -78,7 +75,7 @@ require (
7875
github.com/spf13/pflag v1.0.5 // indirect
7976
github.com/tidwall/match v1.1.1 // indirect
8077
github.com/tidwall/pretty v1.2.1 // indirect
81-
github.com/v2rayA/ahocorasick-domain v0.0.0-20230218160829-122a074c48c8 // indirect
78+
github.com/v2rayA/ahocorasick-domain v0.0.0-20231231085011-99ceb8ef3208 // indirect
8279
github.com/vishvananda/netns v0.0.4 // indirect
8380
github.com/x-cray/logrus-prefixed-formatter v0.5.2 // indirect
8481
gitlab.com/yawning/chacha20.git v0.0.0-20230427033715-7877545b1b37 // indirect
@@ -99,6 +96,4 @@ require (
9996

10097
replace github.com/daeuniverse/dae => ./dae-core
10198

102-
replace github.com/graph-gophers/graphql-transport-ws => github.com/mikhailv/graphql-transport-ws v0.0.0-20230405003623-3bf02386d7ce
103-
10499
// replace github.com/daeuniverse/dae => ../dae

0 commit comments

Comments
 (0)