Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: use loopback ip address instead of alias to improve compatibility #2952

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion configuration/contrib/collectd/collectd.conf
Original file line number Diff line number Diff line change
Expand Up @@ -276,7 +276,7 @@ LoadPlugin unixsock

<Plugin mqtt>
<Publish "name">
Host "localhost"
Host "127.0.0.1"
Port 1883
ClientId "tedge-collectd"
# User "user"
Expand Down
2 changes: 1 addition & 1 deletion crates/common/axum_tls/test_data/_regenerate_certs.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
days=365000
args=("-days" "$days" "-noenc" \
-subj "/CN=localhost" \
-addext "subjectAltName=DNS:localhost,DNS:*.localhost" \
-addext "subjectAltName=DNS:localhost,DNS:*.localhost,IP:127.0.0.1" \
-addext "basicConstraints=critical,CA:false")

set -eux
Expand Down
4 changes: 2 additions & 2 deletions crates/common/mqtt_channel/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ pub struct Config {
pub struct BrokerConfig {
/// MQTT host to connect to
///
/// Default: "localhost"
/// Default: "127.0.0.1"
pub host: String,

/// MQTT port to connect to. Usually it's either 1883 for insecure MQTT and
Expand Down Expand Up @@ -156,7 +156,7 @@ impl Default for Config {
fn default() -> Self {
Config {
broker: BrokerConfig {
host: String::from("localhost"),
host: String::from("127.0.0.1"),
port: 1883,
authentication: None,
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -584,7 +584,7 @@ define_tedge_config! {

client: {
/// The host that the thin-edge MQTT client should connect to
#[tedge_config(example = "localhost", default(value = "localhost"))]
#[tedge_config(example = "127.0.0.1", default(value = "127.0.0.1"))]
host: String,

/// The port that the thin-edge MQTT client should connect to
Expand Down
2 changes: 1 addition & 1 deletion crates/common/tedge_config_macros/examples/macro.rs
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ define_tedge_config! {

client: {
/// The host that the thin-edge MQTT client should connect to
#[tedge_config(example = "localhost", default(value = "localhost"))]
#[tedge_config(example = "127.0.0.1", default(value = "127.0.0.1"))]
host: String,

/// The port that the thin-edge MQTT client should connect to
Expand Down
4 changes: 2 additions & 2 deletions crates/core/tedge/src/bridge/common_mosquitto_config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ impl Default for CommonMosquittoConfig {
config_file: COMMON_MOSQUITTO_CONFIG_FILENAME.into(),
internal_listener: ListenerConfig {
port: Some(1883),
bind_address: Some("localhost".into()),
bind_address: Some("127.0.0.1".into()),
allow_anonymous: true,
require_certificate: false,
..Default::default()
Expand Down Expand Up @@ -237,7 +237,7 @@ mod tests {
.collect();
let mut expected = std::collections::HashSet::new();

expected.insert("listener 1883 localhost");
expected.insert("listener 1883 127.0.0.1");
expected.insert("allow_anonymous true");
expected.insert("connection_messages true");

Expand Down
2 changes: 1 addition & 1 deletion crates/extensions/c8y_mapper_ext/src/converter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3556,7 +3556,7 @@ pub(crate) mod tests {
let device_type = "test-device-type".into();
let tedge_config = TEdgeConfig::load_toml_str("service.ty = \"service\"");
let c8y_host = "test.c8y.io".into();
let tedge_http_host = "localhost".into();
let tedge_http_host = "127.0.0.1".into();
let auth_proxy_addr = "127.0.0.1".into();
let auth_proxy_port = 8001;
let auth_proxy_protocol = Protocol::Http;
Expand Down
2 changes: 1 addition & 1 deletion crates/extensions/tedge_mqtt_bridge/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,7 @@ mod tests {

#[test]
fn sets_certs_in_the_provided_mqtt_config() {
let mut opts = MqttOptions::new("dummy-device", "localhost", 1883);
let mut opts = MqttOptions::new("dummy-device", "127.0.0.1", 1883);
let device_cert = rcgen::generate_simple_self_signed(["dummy-device".into()]).unwrap();
let c8y_cert = rcgen::generate_simple_self_signed(["dummy-c8y".into()]).unwrap();

Expand Down
4 changes: 2 additions & 2 deletions crates/extensions/tedge_mqtt_bridge/tests/bridge.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,13 +37,13 @@ fn new_broker_and_client(name: &str, port: u16) -> (AsyncClient, EventLoop) {
.spawn(move || broker.start().unwrap())
.unwrap();
AsyncClient::new(
MqttOptions::new(format!("{name}-test-client"), "localhost", port),
MqttOptions::new(format!("{name}-test-client"), "127.0.0.1", port),
10,
)
}

async fn start_mqtt_bridge(local_port: u16, cloud_port: u16, rules: BridgeConfig) {
let cloud_config = MqttOptions::new("a-device-id", "localhost", cloud_port);
let cloud_config = MqttOptions::new("a-device-id", "127.0.0.1", cloud_port);
let service_name = "tedge-mapper-test";
let health_topic = format!("te/device/main/service/{service_name}/status/health")
.as_str()
Expand Down
2 changes: 1 addition & 1 deletion crates/tests/mqtt_tests/src/test_mqtt_client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ impl TestCon {
let id: String = std::iter::repeat_with(fastrand::alphanumeric)
.take(10)
.collect();
let mut options = MqttOptions::new(id, "localhost", mqtt_port);
let mut options = MqttOptions::new(id, "127.0.0.1", mqtt_port);
options.set_clean_session(true);

let (client, eventloop) = AsyncClient::new(options, 10);
Expand Down
2 changes: 1 addition & 1 deletion crates/tests/mqtt_tests/src/test_mqtt_server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ fn spawn_broker() -> u16 {
};

std::thread::spawn(move || {
let mut mqttoptions = rumqttc::MqttOptions::new("rumqtt-sync", "localhost", port);
let mut mqttoptions = rumqttc::MqttOptions::new("rumqtt-sync", "127.0.0.1", port);
mqttoptions.set_keep_alive(Duration::from_secs(5));

let (mut client, mut connection) = rumqttc::Client::new(mqttoptions, 10);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ authorityKeyIdentifier=keyid
basicConstraints=CA:FALSE
keyUsage = digitalSignature, keyAgreement
extendedKeyUsage = serverAuth, clientAuth
subjectAltName=DNS:localhost,IP:$C8Y_PROXY_COMMON_NAME
subjectAltName=DNS:localhost,IP:$C8Y_PROXY_COMMON_NAME,IP:127.0.0.1
EOF

openssl x509 -req \
Expand All @@ -49,7 +49,7 @@ authorityKeyIdentifier=keyid
basicConstraints=CA:FALSE
keyUsage = digitalSignature, keyAgreement
extendedKeyUsage = serverAuth, clientAuth
subjectAltName=DNS:localhost,IP:$FTS_COMMON_NAME
subjectAltName=DNS:localhost,IP:$FTS_COMMON_NAME,IP:127.0.0.1
EOF

openssl genrsa -out main-agent.key 2048
Expand Down
2 changes: 1 addition & 1 deletion tests/RobotFramework/tests/mqtt/gen_certs.sh
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ cat > v3.ext << EOF
authorityKeyIdentifier=keyid
basicConstraints=CA:FALSE
keyUsage = digitalSignature, keyAgreement
subjectAltName=DNS:$(hostname),DNS:localhost
subjectAltName=DNS:$(hostname),DNS:localhost,IP:127.0.0.1
EOF

openssl x509 -req \
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -299,7 +299,7 @@ set/unset mqtt.client.host
# Undo the change by using the 'unset' command, value returns to default one
Execute Command sudo tedge config unset mqtt.client.host
${unset} Execute Command tedge config list
Should Contain ${unset} mqtt.client.host=localhost
Should Contain ${unset} mqtt.client.host=127.0.0.1

set/unset mqtt.client.port
Execute Command sudo tedge config set mqtt.client.port 1888
Expand Down
4 changes: 2 additions & 2 deletions tests/images/debian-systemd/files/bootstrap.sh
Original file line number Diff line number Diff line change
Expand Up @@ -695,7 +695,7 @@ gen_certs() {
authorityKeyIdentifier=keyid
basicConstraints=CA:FALSE
keyUsage = digitalSignature, keyAgreement
subjectAltName=DNS:$(hostname), DNS:localhost
subjectAltName=DNS:$(hostname), DNS:localhost, IP:127.0.0.1
EOF

openssl x509 -req \
Expand Down Expand Up @@ -774,7 +774,7 @@ authorityKeyIdentifier=keyid
basicConstraints=CA:FALSE
keyUsage = digitalSignature, keyAgreement
extendedKeyUsage = serverAuth, clientAuth
subjectAltName=DNS:${CN},DNS:localhost
subjectAltName=DNS:${CN},DNS:localhost,IP:127.0.0.1
EOF
)

Expand Down