diff options
author | Daniil Baturin <daniil@vyos.io> | 2025-03-25 15:23:29 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2025-03-25 15:23:29 +0000 |
commit | 920b75a6dbf9eac4b94600b759818b2ec28004ae (patch) | |
tree | 9e91bccfc485d4c0984fdef262ad4c3c90c6ba55 /src | |
parent | 33cc7567d909c776d43ea6698267125ea1ec2f66 (diff) | |
parent | 0767f1f06774f84bd7e6883958af067c51c52255 (diff) | |
download | vyconf-920b75a6dbf9eac4b94600b759818b2ec28004ae.tar.gz vyconf-920b75a6dbf9eac4b94600b759818b2ec28004ae.zip |
Merge pull request #16 from jestabro/strip-version
T7246: strip version strings on config load
Diffstat (limited to 'src')
-rw-r--r-- | src/startup.ml | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/src/startup.ml b/src/startup.ml index db2784d..76599b0 100644 --- a/src/startup.ml +++ b/src/startup.ml @@ -78,12 +78,20 @@ let create_server accept_connection sock = Lwt_unix.accept sock >>= accept_connection >>= serve in serve +(* strip commponent version string *) +let strip_version s = + let rex = Pcre.regexp ~flags:[`MULTILINE;`DOTALL] "(^//.*)" in + let res = Pcre.split ~max:0 ~rex s in + match res with + | h :: _ -> h + | [] -> panic "Failure applying regex to config string" + (** Load the appliance configuration file *) let load_config file = try let chan = open_in file in let s = really_input_string chan (in_channel_length chan) in - let config = Vyos1x.Parser.from_string s in + let config = strip_version s |> Vyos1x.Parser.from_string in Ok config with | Sys_error msg -> Error msg |