fea: support add findhop.

This commit is contained in:
Daniel Ding
2024-08-30 16:31:01 +08:00
parent 65a0ea5624
commit 1af859ed27
27 changed files with 504 additions and 160 deletions

View File

@@ -26,7 +26,7 @@ func (rt Route) List(w http.ResponseWriter, r *http.Request) {
worker := Call.GetWorker(id)
if worker == nil {
http.Error(w, "Network not found", http.StatusInternalServerError)
http.Error(w, "Network not found", http.StatusBadRequest)
return
}
@@ -42,18 +42,18 @@ func (rt Route) Add(w http.ResponseWriter, r *http.Request) {
worker := Call.GetWorker(id)
if worker == nil {
http.Error(w, "Network not found", http.StatusInternalServerError)
http.Error(w, "Network not found", http.StatusBadRequest)
return
}
pr := &schema.PrefixRoute{}
if err := GetData(r, pr); err != nil {
http.Error(w, err.Error(), http.StatusInternalServerError)
http.Error(w, err.Error(), http.StatusBadRequest)
return
}
if err := worker.AddRoute(pr, rt.Switcher); err != nil {
http.Error(w, err.Error(), http.StatusInternalServerError)
http.Error(w, err.Error(), http.StatusBadRequest)
return
}
@@ -66,18 +66,18 @@ func (rt Route) Del(w http.ResponseWriter, r *http.Request) {
worker := Call.GetWorker(id)
if worker == nil {
http.Error(w, "Network not found", http.StatusInternalServerError)
http.Error(w, "Network not found", http.StatusBadRequest)
return
}
pr := &schema.PrefixRoute{}
if err := GetData(r, pr); err != nil {
http.Error(w, err.Error(), http.StatusInternalServerError)
http.Error(w, err.Error(), http.StatusBadRequest)
return
}
if err := worker.DelRoute(pr, rt.Switcher); err != nil {
http.Error(w, err.Error(), http.StatusInternalServerError)
http.Error(w, err.Error(), http.StatusBadRequest)
return
}
@@ -90,7 +90,7 @@ func (rt Route) Save(w http.ResponseWriter, r *http.Request) {
worker := Call.GetWorker(id)
if worker == nil {
http.Error(w, "Network not found", http.StatusInternalServerError)
http.Error(w, "Network not found", http.StatusBadRequest)
return
}