File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -37,6 +37,7 @@ services:
3737 depends_on :
3838 - platform
3939 environment :
40+ LISTEN_PORT : 1331
4041 V2_SERVICE : ret2shell
4142 # extra_hosts:
4243 # - host.docker.internal:host-gateway
Original file line number Diff line number Diff line change @@ -49,20 +49,25 @@ pub struct ServerConfig {
4949impl Config {
5050 pub async fn load ( ) -> Result < Self > {
5151 // Try to load from current directory first
52- if Path :: new ( "config.toml" ) . exists ( ) {
52+ let mut config : Config = if Path :: new ( "config.toml" ) . exists ( ) {
5353 let content = fs:: read_to_string ( "config.toml" ) . await ?;
54- let config: Config = toml:: from_str ( & content) ?;
55- return Ok ( config) ;
56- }
57-
58- // Try to load from /etc/ret2shell/config.toml
59- if Path :: new ( "/etc/ret2shell/config.toml" ) . exists ( ) {
54+ toml:: from_str ( & content) ?
55+ } else if Path :: new ( "/etc/ret2shell/config.toml" ) . exists ( ) {
56+ // Try to load from /etc/ret2shell/config.toml
6057 let content = fs:: read_to_string ( "/etc/ret2shell/config.toml" ) . await ?;
61- let config: Config = toml:: from_str ( & content) ?;
62- return Ok ( config) ;
58+ toml:: from_str ( & content) ?
59+ } else {
60+ anyhow:: bail!(
61+ "Config file not found in current directory or /etc/ret2shell/config.toml"
62+ ) ;
63+ } ;
64+
65+ // Override with environment variables if specified
66+ if let Ok ( server_port) = std:: env:: var ( "LISTEN_PORT" ) {
67+ config. server . port = server_port;
6368 }
6469
65- anyhow :: bail! ( "Config file not found in current directory or /etc/ret2shell/ config.toml" ) ;
70+ Ok ( config)
6671 }
6772
6873 pub fn database_url ( & self ) -> String {
You can’t perform that action at this time.
0 commit comments