Skip to content

Commit 2309753

Browse files
committed
revert back to host network with 127.0.0.1
1 parent 6f94cc1 commit 2309753

File tree

3 files changed

+36
-20
lines changed

3 files changed

+36
-20
lines changed

examples/justfile

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -220,16 +220,20 @@ ipfs-start test_dir: _check-docker
220220
# Pull latest kubo image if not present
221221
docker pull ipfs/kubo:latest
222222

223-
# Use bridge network mode
224-
NETWORK_ARGS="-p 4001:4001 -p 8080:8080 -p 5001:5001"
223+
# Determine network mode based on OS
224+
if [[ "$OSTYPE" == "darwin"* ]]; then
225+
# macOS - use bridge with port mapping
226+
NETWORK_ARGS="-p 4001:4001 -p 8080:8080 -p 5001:5001"
227+
else
228+
# Linux (including CI) - use host networking so container can reach localhost services
229+
NETWORK_ARGS="--network host"
230+
fi
225231

226232
# Start Docker container
227233
docker run -d --name ipfs-node -v ipfs-data:/data/ipfs $NETWORK_ARGS ipfs/kubo:latest
228-
echo " Container: ipfs-node"
229-
echo " NETWORK_ARGS: $NETWORK_ARGS"
234+
echo " Container: ipfs-node (network: $NETWORK_ARGS)"
230235
echo " Waiting for container to start..."
231236
sleep 5
232-
docker inspect ipfs-node --format '{{{{.HostConfig.NetworkMode}}}}'
233237
docker exec ipfs-node ipfs --version
234238

235239
# Bitswap logging
@@ -249,13 +253,13 @@ ipfs-connect runtime:
249253

250254
# Detect the correct host and protocol for Docker
251255
if [[ "$OSTYPE" == "darwin"* ]]; then
252-
# macOS - use dns4/host.docker.internal
256+
# macOS - use dns4/host.docker.internal (bridge network)
253257
PROTOCOL="dns4"
254258
DOCKER_HOST="host.docker.internal"
255259
else
256-
# Linux (with bridge networking) - use ip4/172.17.0.1
260+
# Linux - use ip4/127.0.0.1 (host network mode)
257261
PROTOCOL="ip4"
258-
DOCKER_HOST="172.17.0.1"
262+
DOCKER_HOST="127.0.0.1"
259263
fi
260264

261265
echo " Using Docker host: /$PROTOCOL/$DOCKER_HOST"
@@ -298,9 +302,9 @@ ipfs-reconnect-start test_dir runtime:
298302
cd "$ROOT_DIR"
299303
# TODO: improve this for multiple runtimes
300304
if [ "{{ runtime }}" = "bulletin-westend-runtime" ]; then
301-
./scripts/ipfs-reconnect-westend.sh docker > {{ test_dir }}/ipfs-reconnect.log 2>&1 &
305+
./scripts/ipfs-reconnect-westend.sh docker 10 > {{ test_dir }}/ipfs-reconnect.log 2>&1 &
302306
elif [ "{{ runtime }}" = "bulletin-polkadot-runtime" ]; then
303-
./scripts/ipfs-reconnect-solo.sh docker > {{ test_dir }}/ipfs-reconnect.log 2>&1 &
307+
./scripts/ipfs-reconnect-solo.sh docker 10 > {{ test_dir }}/ipfs-reconnect.log 2>&1 &
304308
else
305309
echo "🐳 Unhandled runtime: {{ runtime }} specified!"
306310
exit 1

scripts/ipfs-reconnect-solo.sh

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,20 +2,31 @@
22

33
THIS_DIR=$(cd $(dirname $0); pwd)
44

5-
# Choose mode based on argument
5+
# Arguments: mode [sleep_interval]
66
mode="${1:-local}"
7+
sleep_interval="${2:-2}"
78
if [ "$mode" = "docker" ]; then
89
check_cmd="docker exec ipfs-node ipfs"
9-
check_host="172.17.0.1"
10+
11+
if [[ "$OSTYPE" == "darwin"* ]]; then
12+
# macOS - use dns4/host.docker.internal (bridge network)
13+
check_protocol="dns4"
14+
check_host="host.docker.internal"
15+
else
16+
# Linux - use ip4/127.0.0.1 (host network mode)
17+
check_protocol="ip4"
18+
check_host="127.0.0.1"
19+
fi
1020
else
1121
check_cmd="${THIS_DIR}/../kubo/ipfs"
22+
check_protocol="ip4"
1223
check_host="127.0.0.1"
1324
fi
1425

1526
# Peers to monitor
1627
PEERS_TO_CHECK=(
17-
"/ip4/${check_host}/tcp/10001/ws/p2p/12D3KooWQCkBm1BYtkHpocxCwMgR8yjitEeHGx8spzcDLGt2gkBm"
18-
"/ip4/${check_host}/tcp/12347/ws/p2p/12D3KooWRkZhiRhsqmrQ28rt73K7V3aCBpqKrLGSXmZ99PTcTZby"
28+
"/${check_protocol}/${check_host}/tcp/10001/ws/p2p/12D3KooWQCkBm1BYtkHpocxCwMgR8yjitEeHGx8spzcDLGt2gkBm"
29+
"/${check_protocol}/${check_host}/tcp/12347/ws/p2p/12D3KooWRkZhiRhsqmrQ28rt73K7V3aCBpqKrLGSXmZ99PTcTZby"
1930
)
2031

2132
while true; do
@@ -32,5 +43,5 @@ while true; do
3243
fi
3344
done
3445

35-
sleep 2
46+
sleep "$sleep_interval"
3647
done

scripts/ipfs-reconnect-westend.sh

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,19 +2,20 @@
22

33
THIS_DIR=$(cd $(dirname $0); pwd)
44

5-
# Choose mode based on argument
5+
# Arguments: mode [sleep_interval]
66
mode="${1:-local}"
7+
sleep_interval="${2:-2}"
78
if [ "$mode" = "docker" ]; then
89
check_cmd="docker exec ipfs-node ipfs"
910

1011
if [[ "$OSTYPE" == "darwin"* ]]; then
11-
# macOS - use dns4/host.docker.internal
12+
# macOS - use dns4/host.docker.internal (bridge network)
1213
check_protocol="dns4"
1314
check_host="host.docker.internal"
1415
else
15-
# Linux (with bridge networking) - use ip4/172.17.0.1
16+
# Linux - use ip4/127.0.0.1 (host network mode)
1617
check_protocol="ip4"
17-
check_host="172.17.0.1"
18+
check_host="127.0.0.1"
1819
fi
1920
else
2021
check_cmd="${THIS_DIR}/../kubo/ipfs"
@@ -42,5 +43,5 @@ while true; do
4243
fi
4344
done
4445

45-
sleep 2
46+
sleep "$sleep_interval"
4647
done

0 commit comments

Comments
 (0)