2021-03-07 04:39:50 +00:00
|
|
|
package conf
|
|
|
|
|
2024-06-29 18:32:57 +00:00
|
|
|
import "github.com/xtls/xray-core/common/errors"
|
|
|
|
|
2021-03-07 04:39:50 +00:00
|
|
|
type ConfigureFilePostProcessingStage interface {
|
|
|
|
Process(conf *Config) error
|
|
|
|
}
|
|
|
|
|
|
|
|
var configureFilePostProcessingStages map[string]ConfigureFilePostProcessingStage
|
|
|
|
|
|
|
|
func RegisterConfigureFilePostProcessingStage(name string, stage ConfigureFilePostProcessingStage) {
|
|
|
|
if configureFilePostProcessingStages == nil {
|
|
|
|
configureFilePostProcessingStages = make(map[string]ConfigureFilePostProcessingStage)
|
|
|
|
}
|
|
|
|
configureFilePostProcessingStages[name] = stage
|
|
|
|
}
|
|
|
|
|
|
|
|
func PostProcessConfigureFile(conf *Config) error {
|
|
|
|
for k, v := range configureFilePostProcessingStages {
|
|
|
|
if err := v.Process(conf); err != nil {
|
2024-06-29 18:32:57 +00:00
|
|
|
return errors.New("Rejected by Postprocessing Stage ", k).AtError().Base(err)
|
2021-03-07 04:39:50 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
return nil
|
|
|
|
}
|