diff --git a/spec/fixtures/defaults_config.yaml b/spec/fixtures/defaults_config.yaml index 55f14fd..71b57fe 100644 --- a/spec/fixtures/defaults_config.yaml +++ b/spec/fixtures/defaults_config.yaml @@ -73,9 +73,10 @@ encoding: hextile_improved_compression: true server: + http: + httpd_directory: /usr/share/kasmvnc/www advanced: x_font_path: auto - httpd_directory: /usr/share/kasmvnc/www kasm_password_file: ~/.kasmpasswd x_authority_file: auto auto_shutdown: diff --git a/unix/KasmVNC/CliOption.pm b/unix/KasmVNC/CliOption.pm index 1088d4b..e696e2b 100644 --- a/unix/KasmVNC/CliOption.pm +++ b/unix/KasmVNC/CliOption.pm @@ -33,6 +33,16 @@ sub new { scalar $self->configValues() > 0; }, + toStringSub => $args->{toStringSub} || sub { + my $self = shift; + + my $derivedValue = $self->deriveValue(); + if (defined($derivedValue)) { + return "-$self->{name} " . "'$derivedValue'"; + } + + "-$self->{name}"; + }, errors => [] }, $class; } @@ -75,12 +85,7 @@ sub toString { return unless $self->isActive(); - my $derivedValue = $self->deriveValue(); - if (defined($derivedValue)) { - return "-$self->{name} " . "'$derivedValue'"; - } - - "-$self->{name}"; + $self->{toStringSub}->($self); } sub toValue { diff --git a/unix/kasmvnc_defaults.yaml b/unix/kasmvnc_defaults.yaml index a6a4211..a4997e2 100644 --- a/unix/kasmvnc_defaults.yaml +++ b/unix/kasmvnc_defaults.yaml @@ -15,6 +15,7 @@ network: udp: public_ip: auto port: auto + stun_server: auto ssl: pem_certificate: /etc/ssl/certs/ssl-cert-snakeoil.pem pem_key: /etc/ssl/private/ssl-cert-snakeoil.key @@ -117,9 +118,13 @@ encoding: hextile_improved_compression: true server: + http: + headers: + - Cross-Origin-Embedder-Policy=require-corp + - Cross-Origin-Opener-Policy=same-origin + httpd_directory: /usr/share/kasmvnc/www advanced: x_font_path: auto - httpd_directory: /usr/share/kasmvnc/www kasm_password_file: ${HOME}/.kasmpasswd x_authority_file: auto auto_shutdown: diff --git a/unix/vncserver b/unix/vncserver index 96709cc..cae50ac 100755 --- a/unix/vncserver +++ b/unix/vncserver @@ -1962,11 +1962,32 @@ sub DefineConfigToCLIConversion { name => 'httpd', configKeys => [ KasmVNC::ConfigKey->new({ - name => "server.advanced.httpd_directory", + name => "server.http.httpd_directory", type => KasmVNC::ConfigKey::ANY }) ] }), + KasmVNC::CliOption->new({ + name => 'http-header', + configKeys => [ + KasmVNC::ConfigKey->new({ + name => "server.http.headers", + type => KasmVNC::ConfigKey::ANY + }) + ], + toStringSub => sub { + $self = shift; + + my @values = @{ listify($self->configValues()) }; + + my $valuesStr = ""; + foreach $value (@values) { + $valuesStr = $valuesStr . "-http-header '$value' " + } + chop($valuesStr); + return $valuesStr; + } + }), KasmVNC::CliOption->new({ name => 'IgnoreClientSettingsKasm', configKeys => [ @@ -2199,6 +2220,24 @@ sub DefineConfigToCLIConversion { isActiveSub => sub { $self = shift; + my $value = $self->configValue(); + isPresent($value) && $value ne 'auto'; + } + }), + KasmVNC::CliOption->new({ + name => 'StunServer', + configKeys => [ + KasmVNC::ConfigKey->new({ + name => "network.udp.stun_server", + validator => KasmVNC::PatternValidator->new({ + pattern => qr/^(auto|\S+)$/, + errorMessage => "must be 'auto' or an IP address/hostname" + }), + }) + ], + isActiveSub => sub { + $self = shift; + my $value = $self->configValue(); isPresent($value) && $value ne 'auto'; } @@ -2644,7 +2683,9 @@ sub ConfigToCmd { %optFromConfig = %{ ConstructOptFromConfig() }; my @cmd = map { $cliArgMap{$_}->toString() } (keys %optFromConfig); - " " . join " ", @cmd; + my $cmdStr = " " . join " ", @cmd; + + return $cmdStr; } sub ValidateConfig {