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

Add Get IPV4/6 from Network service #327

Closed
wants to merge 18 commits into from
Closed
Changes from 11 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
28 changes: 28 additions & 0 deletions src/service/network.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,9 @@ export class Wifi extends Service {
'ssid': ['string'],
'state': ['string'],
'icon-name': ['string'],
'ipv4-address': ['string'],
'ipv6-address': ['string'],

});
}

Expand All @@ -89,6 +92,14 @@ export class Wifi extends Service {
]);
this._activeAp();
}
const ip4Config = this._device.ip4_config;
const ip6Config = this._device.ip6_config;

if ((this._device) && (ip4Config))
ip4Config.connect('notify::addresses', () => this.changed('ipv4-address'));

if ((this._device) && (ip6Config))
ip6Config.connect('notify::addresses', () => this.changed('ipv6-address'));
Lanpingner marked this conversation as resolved.
Show resolved Hide resolved
}

readonly scan = () => {
Expand Down Expand Up @@ -131,6 +142,8 @@ export class Wifi extends Service {

get enabled() { return this._client.wireless_enabled; }
set enabled(v) { this._client.wireless_enabled = v; }
get ipv4Address() { return this._device.ip4_config.get_addresses(); }
get ipv6Address() { return this._device.ip6_config.get_addresses(); }
Lanpingner marked this conversation as resolved.
Show resolved Hide resolved

get strength() { return this._ap?.strength || -1; }
get internet() { return _INTERNET(this._device); }
Expand Down Expand Up @@ -180,6 +193,8 @@ export class Wired extends Service {
'internet': ['string'],
'state': ['string'],
'icon-name': ['string'],
'ipv4-address': ['string'],
'ipv6-address': ['string'],
});
}

Expand All @@ -195,8 +210,19 @@ export class Wired extends Service {
['speed', 'internet', 'state', 'icon-name']
.map(prop => this.notify(prop));
});

const ip4Config = this._device.ip4_config;
const ip6Config = this._device.ip6_config;

if ((this._device) && (ip4Config))
ip4Config.connect('notify::addresses', () => this.changed('ipv4-address'));

if ((this._device) && (ip6Config))
ip6Config.connect('notify::addresses', () => this.changed('ipv6-address'));
}

get ipv4Address() { return this._device.ip4_config.get_addresses(); }
get ipv6Address() { return this._device.ip6_config.get_addresses(); }
get speed() { return this._device.get_speed(); }
get internet() { return _INTERNET(this._device); }
get state() { return _DEVICE_STATE(this._device); }
Expand All @@ -221,6 +247,8 @@ export class Network extends Service {
'wired': ['jsobject'],
'primary': ['string'],
'connectivity': ['string'],
'ipv4-address': ['string'],
'ipv6-address': ['string'],
Lanpingner marked this conversation as resolved.
Show resolved Hide resolved
});
}

Expand Down