2021-03-07 07:39:50 +03:00
|
|
|
package conf
|
|
|
|
|
2024-06-29 21:32:57 +03:00
|
|
|
import "github.com/xtls/xray-core/common/errors"
|
|
|
|
|
2021-03-07 07:39:50 +03: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 21:32:57 +03:00
|
|
|
return errors.New("Rejected by Postprocessing Stage ", k).AtError().Base(err)
|
2021-03-07 07:39:50 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
return nil
|
|
|
|
}
|