parse and handle config; put Apache 2.0 License
This commit is contained in:
56
bounce.go
Normal file
56
bounce.go
Normal file
@@ -0,0 +1,56 @@
|
||||
package netbounce
|
||||
|
||||
/*
|
||||
Copyright 2025 Suyono <suyono3484@gmail.com>
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"gitea.suyono.dev/suyono/netbounce/abstract"
|
||||
"gitea.suyono.dev/suyono/netbounce/config"
|
||||
)
|
||||
|
||||
func Bounce() error {
|
||||
var (
|
||||
names []string
|
||||
err error
|
||||
cc abstract.ConnectionConfig
|
||||
)
|
||||
|
||||
if names, err = config.ListConnection(); err != nil {
|
||||
return fmt.Errorf("bounce: connection list: %w", err)
|
||||
}
|
||||
for _, name := range names {
|
||||
if cc, err = config.GetConnection(name); err != nil {
|
||||
return fmt.Errorf("bounce: connection get %s: %w", name, err)
|
||||
}
|
||||
|
||||
if cc.Type() == abstract.TCP {
|
||||
go RunTCP(cc.AsTCP())
|
||||
} else {
|
||||
go RunUDP(cc.AsUDP())
|
||||
}
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func RunTCP(cfg abstract.TCPConnectionConfig) {
|
||||
|
||||
}
|
||||
|
||||
func RunUDP(cfg abstract.UDPConnectionConfig) {
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user