File tree Expand file tree Collapse file tree 2 files changed +23
-12
lines changed Expand file tree Collapse file tree 2 files changed +23
-12
lines changed Original file line number Diff line number Diff line change @@ -37,19 +37,30 @@ get_local_ip() {
3737# Function to check if CodeQuill is running on another device (parallelized)
3838check_remote_codequill () {
3939 local network_prefix=$( echo $1 | cut -d. -f1-3)
40- local ip_list=($( seq 1 254 | xargs -I {} echo " ${network_prefix} .{}" ) )
41- local -a pids=()
42-
43- for ip in " ${ip_list[@]} " ; do
44- if [ " $ip " != " $1 " ]; then
45- (nc -z -w 1 $ip $PORT && echo $ip ) &
46- pids+=($! )
40+ local last_ip_file=" $HOME /.codequill_last_ip"
41+
42+ # Check last known IP first if available
43+ if [ -f " $last_ip_file " ]; then
44+ local last_ip=$( cat " $last_ip_file " )
45+ if nc -z -w 1 $last_ip $PORT 2> /dev/null; then
46+ echo $last_ip
47+ return
4748 fi
48- done
49+ fi
4950
50- for pid in " ${pids[@]} " ; do
51- wait $pid
52- done | head -n 1
51+ # Parallel scan using GNU Parallel if available
52+ if command -v parallel & > /dev/null; then
53+ parallel -j0 --halt now,success=1 " nc -z -w 1 $network_prefix .{} $PORT && echo $network_prefix .{}" ::: {1..254} 2> /dev/null | head -n1
54+ else
55+ for i in {1..254}; do
56+ local ip=" $network_prefix .$i "
57+ if [ " $ip " != " $1 " ] && nc -z -w 1 $ip $PORT 2> /dev/null; then
58+ echo $ip
59+ echo $ip > " $last_ip_file "
60+ return
61+ fi
62+ done
63+ fi
5364}
5465
5566LOCAL_IP=$( get_local_ip)
Original file line number Diff line number Diff line change 33 "author" : " The-Best-Codes" ,
44 "license" : " MIT" ,
55 "description" : " Organize, Edit, and Share your Code Snippets" ,
6- "version" : " 1.1.8 " ,
6+ "version" : " 1.1.9 " ,
77 "private" : true ,
88 "scripts" : {
99 "dev" : " next dev" ,
You can’t perform that action at this time.
0 commit comments