Skip to content

Commit

Permalink
Make source tcp listener address configurable
Browse files Browse the repository at this point in the history
To allow listening on different interfaces for incoming connections, the
tcp listener address is made configurable.
Additionally, it is set to "0.0.0.0" such that the source server reader
listens on all interfaces per default.
  • Loading branch information
AntonOellerer committed Mar 15, 2023
1 parent df23792 commit 345ce8a
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 6 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@ All other sections are for end-users.

- (Breaking Change) Remove `TimedStream` from foreign-service ([#250](https://github.com/SpringQL/SpringQL/pull/250)

### Fixed
- Make TCP server source address configurable, set it to "0.0.0.0" per default ([#260](https://github.com/SpringQL/SpringQL/pull/260))

## [v0.18.1] - 2022-10-07

### For developers
Expand Down
2 changes: 1 addition & 1 deletion springql-core/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "springql-core"
version = "0.18.1"
version = "0.18.2"

authors = ["Sho Nakatani <lay.sakura@gmail.com>"]
license = "MIT OR Apache-2.0"
Expand Down
2 changes: 2 additions & 0 deletions springql-core/src/api/spring_config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ timeout_msec = 3_000
[source_reader]
net_connect_timeout_msec = 1_000
net_read_timeout_msec = 100
net_address = "0.0.0.0"
can_read_timeout_msec = 100
Expand Down Expand Up @@ -179,6 +180,7 @@ pub struct SpringWebConsoleConfig {
pub struct SpringSourceReaderConfig {
pub net_connect_timeout_msec: u32,
pub net_read_timeout_msec: u32,
pub net_address: String,

pub can_read_timeout_msec: u32,
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ impl SourceReader for NetServerSourceReader {
"unsupported protocol"
);

let listener = TcpListener::bind(("127.0.0.1", options.port)).unwrap();
let listener = TcpListener::bind((config.net_address.clone(), options.port)).unwrap();
let my_addr = listener.local_addr().unwrap();

let (tx, rx) = mpsc::channel();
Expand Down Expand Up @@ -94,10 +94,10 @@ impl NetServerSourceReader {
}

fn stream_handler(stream: TcpStream, tx: mpsc::Sender<serde_json::Value>) {
log::info!(
"[NetServerSourceReader] Connection from {}",
stream.peer_addr().unwrap()
);
// log::info!(
// "[NetServerSourceReader] Connection from {}",
// stream.peer_addr().unwrap()
// );

let mut tcp_reader = BufReader::new(stream);

Expand Down

0 comments on commit 345ce8a

Please sign in to comment.