mirror of
https://github.com/Buriburizaem0n/nezha_domains.git
synced 2026-02-06 13:40:06 +00:00
refactor nat
This commit is contained in:
@@ -159,6 +159,11 @@ func dispatchReportInfoTask() {
|
||||
|
||||
func newHTTPandGRPCMux(httpHandler http.Handler, grpcHandler http.Handler) http.Handler {
|
||||
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||
natConfig := singleton.GetNATConfigByDomain(r.Host)
|
||||
if natConfig != nil {
|
||||
rpc.ServeNAT(w, r, natConfig)
|
||||
return
|
||||
}
|
||||
if r.ProtoMajor == 2 && r.Header.Get("Content-Type") == "application/grpc" &&
|
||||
strings.HasPrefix(r.URL.Path, "/"+proto.NezhaService_ServiceDesc.ServiceName) {
|
||||
grpcHandler.ServeHTTP(w, r)
|
||||
|
||||
Reference in New Issue
Block a user