2022-08-12 06:02:06 -04:00
|
|
|
package core
|
2022-07-28 11:00:05 -04:00
|
|
|
|
|
|
|
import (
|
|
|
|
"context"
|
|
|
|
"fmt"
|
|
|
|
"github.com/xtls/xray-core/core"
|
|
|
|
"github.com/xtls/xray-core/features/inbound"
|
|
|
|
)
|
|
|
|
|
2022-08-12 06:02:06 -04:00
|
|
|
func (p *Core) RemoveInbound(tag string) error {
|
2022-09-07 11:02:02 -04:00
|
|
|
return p.ihm.RemoveHandler(context.Background(), tag)
|
2022-07-28 11:00:05 -04:00
|
|
|
}
|
|
|
|
|
2022-08-12 06:02:06 -04:00
|
|
|
func (p *Core) AddInbound(config *core.InboundHandlerConfig) error {
|
2022-07-28 11:00:05 -04:00
|
|
|
rawHandler, err := core.CreateObject(p.Server, config)
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
handler, ok := rawHandler.(inbound.Handler)
|
|
|
|
if !ok {
|
|
|
|
return fmt.Errorf("not an InboundHandler: %s", err)
|
|
|
|
}
|
2022-08-12 06:02:06 -04:00
|
|
|
if err := p.ihm.AddHandler(context.Background(), handler); err != nil {
|
2022-07-28 11:00:05 -04:00
|
|
|
return err
|
|
|
|
}
|
|
|
|
return nil
|
|
|
|
}
|