Skip to content

Commit 004169c

Browse files
author
sweet.yangyz
committed
Add clear method.
1 parent f6bd256 commit 004169c

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

api/http/server.go

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,24 @@ func apiHandler(w http.ResponseWriter, r *http.Request) {
8181
log.Error("Error: %s", err.Error())
8282
}
8383
fmt.Fprintf(w, "### %s ###:\n%s", throttler.TcList, string(tcOut))
84+
case "clear":
85+
log.Info("Start forcing to clear all tc qdisc")
86+
for _, m := range Muxy.MiddleWares() {
87+
log.Debug("%s", reflect.TypeOf(m))
88+
89+
switch v := m.(type) {
90+
case *middleware.LoggerMiddleware:
91+
log.Debug("Not support %v yet.", v)
92+
case *symptom.HTTPDelaySymptom:
93+
log.Debug("Not support %v yet.", v)
94+
case *symptom.NetworkShaperSymptom:
95+
log.Debug("Not support %v yet.", v)
96+
}
97+
98+
}
8499

100+
log.Info("Forcing clear all tc qdisc successfully")
101+
fmt.Fprint(w, "Forcing to clear all tc qdisc successfully.")
85102
case "reset":
86103
//e.g. body = {"Device":"ens33","Latency": 2000, "TargetBandWidth":20,"PacketLoss":70,"TargetPorts": ["5001","10090"], "TargetProtos":["tcp","icmp"]}
87104
log.Info("Reset the middlewares, please wait.")

0 commit comments

Comments
 (0)