Updated node-unifi and unifiController.js
This commit is contained in:
parent
7a3bab7c61
commit
99a355a456
34
server/package-lock.json
generated
34
server/package-lock.json
generated
|
@ -22,7 +22,7 @@
|
||||||
"jsonwebtoken": "^8.5.1",
|
"jsonwebtoken": "^8.5.1",
|
||||||
"ldapjs": "^1.0.2",
|
"ldapjs": "^1.0.2",
|
||||||
"node-cron": "^2.0.3",
|
"node-cron": "^2.0.3",
|
||||||
"node-unifi": "^1.2.2",
|
"node-unifi": "^1.3.8",
|
||||||
"uuid": "^3.4.0"
|
"uuid": "^3.4.0"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
|
@ -5111,14 +5111,19 @@
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/node-unifi": {
|
"node_modules/node-unifi": {
|
||||||
"version": "1.2.2",
|
"version": "1.3.8",
|
||||||
"resolved": "https://registry.npmjs.org/node-unifi/-/node-unifi-1.2.2.tgz",
|
"resolved": "https://registry.npmjs.org/node-unifi/-/node-unifi-1.3.8.tgz",
|
||||||
"integrity": "sha1-ObpLOgIzwNNwm2Rz7vAdv3/W9E8=",
|
"integrity": "sha512-4aYQZlp8O00G2BH6vZVH/N6/ZBrRyNai4huraHCLoGQFe0jD2a1Xtjgmtu6NBGx3ILBpkTYfaVnMZSPlyq5gEQ==",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"async": "^2.1.4",
|
"async": "^3.2.0",
|
||||||
"request": "^2.69.0"
|
"request": "^2.88.2"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"node_modules/node-unifi/node_modules/async": {
|
||||||
|
"version": "3.2.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/async/-/async-3.2.0.tgz",
|
||||||
|
"integrity": "sha512-TR2mEZFVOj2pLStYxLht7TyfuRzaydfpxr3k9RpHIzMgw7A64dzsdqCxH1WJyQdoe8T10nDXd9wnEigmiuHIZw=="
|
||||||
|
},
|
||||||
"node_modules/nodemon": {
|
"node_modules/nodemon": {
|
||||||
"version": "2.0.6",
|
"version": "2.0.6",
|
||||||
"resolved": "https://registry.npmjs.org/nodemon/-/nodemon-2.0.6.tgz",
|
"resolved": "https://registry.npmjs.org/nodemon/-/nodemon-2.0.6.tgz",
|
||||||
|
@ -11982,12 +11987,19 @@
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node-unifi": {
|
"node-unifi": {
|
||||||
"version": "1.2.2",
|
"version": "1.3.8",
|
||||||
"resolved": "https://registry.npmjs.org/node-unifi/-/node-unifi-1.2.2.tgz",
|
"resolved": "https://registry.npmjs.org/node-unifi/-/node-unifi-1.3.8.tgz",
|
||||||
"integrity": "sha1-ObpLOgIzwNNwm2Rz7vAdv3/W9E8=",
|
"integrity": "sha512-4aYQZlp8O00G2BH6vZVH/N6/ZBrRyNai4huraHCLoGQFe0jD2a1Xtjgmtu6NBGx3ILBpkTYfaVnMZSPlyq5gEQ==",
|
||||||
"requires": {
|
"requires": {
|
||||||
"async": "^2.1.4",
|
"async": "^3.2.0",
|
||||||
"request": "^2.69.0"
|
"request": "^2.88.2"
|
||||||
|
},
|
||||||
|
"dependencies": {
|
||||||
|
"async": {
|
||||||
|
"version": "3.2.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/async/-/async-3.2.0.tgz",
|
||||||
|
"integrity": "sha512-TR2mEZFVOj2pLStYxLht7TyfuRzaydfpxr3k9RpHIzMgw7A64dzsdqCxH1WJyQdoe8T10nDXd9wnEigmiuHIZw=="
|
||||||
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"nodemon": {
|
"nodemon": {
|
||||||
|
|
|
@ -44,7 +44,7 @@
|
||||||
"jsonwebtoken": "^8.5.1",
|
"jsonwebtoken": "^8.5.1",
|
||||||
"ldapjs": "^1.0.2",
|
"ldapjs": "^1.0.2",
|
||||||
"node-cron": "^2.0.3",
|
"node-cron": "^2.0.3",
|
||||||
"node-unifi": "^1.2.2",
|
"node-unifi": "^1.3.8",
|
||||||
"uuid": "^3.4.0"
|
"uuid": "^3.4.0"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -28,11 +28,7 @@ const Query = {
|
||||||
|
|
||||||
async users(
|
async users(
|
||||||
_,
|
_,
|
||||||
{
|
{ where: { cn, displayName, sAMAccountName }, limit, onlyStudents },
|
||||||
where: { cn, displayName, sAMAccountName },
|
|
||||||
limit,
|
|
||||||
onlyStudents
|
|
||||||
},
|
|
||||||
{ ad }
|
{ ad }
|
||||||
) {
|
) {
|
||||||
const parsedSAMAccountName = parseSAMAccountName(sAMAccountName)
|
const parsedSAMAccountName = parseSAMAccountName(sAMAccountName)
|
||||||
|
|
|
@ -1,12 +1,12 @@
|
||||||
import unifi from 'node-unifi'
|
import { Controller } from 'node-unifi'
|
||||||
import { promisify } from 'util'
|
import { promisify } from 'util'
|
||||||
|
|
||||||
const unifiController = new unifi.Controller(
|
const unifiController = new Controller(
|
||||||
process.env.UNIFI_URL || 'unifi.pp.ifms.edu.br',
|
process.env.UNIFI_URL || 'unifi.pp.ifms.edu.br',
|
||||||
process.env.UNIFI_PORT || 8443
|
process.env.UNIFI_PORT || 8443
|
||||||
)
|
)
|
||||||
|
|
||||||
const keys = [
|
const usedControllerMethods = [
|
||||||
'login',
|
'login',
|
||||||
'logout',
|
'logout',
|
||||||
'authorizeGuest',
|
'authorizeGuest',
|
||||||
|
@ -14,12 +14,24 @@ const keys = [
|
||||||
'reconnectClient',
|
'reconnectClient',
|
||||||
'blockClient',
|
'blockClient',
|
||||||
'unblockClient',
|
'unblockClient',
|
||||||
|
'forgetClient',
|
||||||
|
'createUser',
|
||||||
'setClientNote',
|
'setClientNote',
|
||||||
'setClientName',
|
'setClientName',
|
||||||
'getDailySiteStats',
|
'get5minSiteStats',
|
||||||
'getHourlySiteStats',
|
'getHourlySiteStats',
|
||||||
|
'getDailySiteStats',
|
||||||
|
'get5minApStats',
|
||||||
'getHourlyApStats',
|
'getHourlyApStats',
|
||||||
'getDailyApStats',
|
'getDailyApStats',
|
||||||
|
'get5minUserStats',
|
||||||
|
'getHourlyUserStats',
|
||||||
|
'getDailyUserStats',
|
||||||
|
'get5minGatewayStats',
|
||||||
|
'getHourlyGatewayStats',
|
||||||
|
'getDailyGatewayStats',
|
||||||
|
'getSpeedTestResults',
|
||||||
|
'getIPSEvents',
|
||||||
'getSessions',
|
'getSessions',
|
||||||
'getLatestSessions',
|
'getLatestSessions',
|
||||||
'getAllAuthorizations',
|
'getAllAuthorizations',
|
||||||
|
@ -28,25 +40,49 @@ const keys = [
|
||||||
'getGuests',
|
'getGuests',
|
||||||
'getClientDevices',
|
'getClientDevices',
|
||||||
'getClientDevice',
|
'getClientDevice',
|
||||||
'getUserGroups',
|
|
||||||
'setUserGroup',
|
'setUserGroup',
|
||||||
|
'editClientFixedIP',
|
||||||
|
'getUserGroups',
|
||||||
|
'createUserGroup',
|
||||||
'editUserGroup',
|
'editUserGroup',
|
||||||
'addUserGroup',
|
|
||||||
'deleteUserGroup',
|
'deleteUserGroup',
|
||||||
|
'getFirewallGroups',
|
||||||
|
'createFirewallGroup',
|
||||||
|
'editFirewallGroup',
|
||||||
|
'deleteFirewallGroup',
|
||||||
|
'getFirewallRules',
|
||||||
|
'getRouting',
|
||||||
'getHealth',
|
'getHealth',
|
||||||
'getDashboard',
|
'getDashboard',
|
||||||
'getUsers',
|
'getUsers',
|
||||||
'getAccessDevices',
|
'getAccessDevices',
|
||||||
|
'listTags',
|
||||||
'getRogueAccessPoints',
|
'getRogueAccessPoints',
|
||||||
|
'getKnownRogueAccessPoints',
|
||||||
|
'generateBackup',
|
||||||
|
'getBackups',
|
||||||
|
'deleteBackup',
|
||||||
'getSites',
|
'getSites',
|
||||||
'getSitesStats',
|
'getSitesStats',
|
||||||
'addSite',
|
'createSite',
|
||||||
'deleteSite',
|
'deleteSite',
|
||||||
|
'setSiteName',
|
||||||
|
'setSiteCountry',
|
||||||
|
'setSiteLocale',
|
||||||
|
'setSiteSNMP',
|
||||||
|
'setSiteMgmt',
|
||||||
|
'setSiteGuestAccess',
|
||||||
|
'setSiteNTP',
|
||||||
|
'setSiteConnectivity',
|
||||||
'listAdmins',
|
'listAdmins',
|
||||||
|
'listAllAdmins',
|
||||||
|
'inviteAdmin',
|
||||||
|
'assignExistingAdmin',
|
||||||
|
'revokeAdmin',
|
||||||
'getWLanGroups',
|
'getWLanGroups',
|
||||||
'getSiteSysinfo',
|
'getSiteSysinfo',
|
||||||
|
'getStatus',
|
||||||
'getSelf',
|
'getSelf',
|
||||||
'getNetworkConf',
|
|
||||||
'getVouchers',
|
'getVouchers',
|
||||||
'getPayments',
|
'getPayments',
|
||||||
'createHotspotOperator',
|
'createHotspotOperator',
|
||||||
|
@ -56,41 +92,76 @@ const keys = [
|
||||||
'extendGuestValidity',
|
'extendGuestValidity',
|
||||||
'getPortForwardingStats',
|
'getPortForwardingStats',
|
||||||
'getDPIStats',
|
'getDPIStats',
|
||||||
|
'getFilteredDPIStats',
|
||||||
|
'ClearDPIStatus',
|
||||||
'getCurrentChannels',
|
'getCurrentChannels',
|
||||||
|
'getCountryCodes',
|
||||||
'getPortForwarding',
|
'getPortForwarding',
|
||||||
'getDynamicDNS',
|
'getDynamicDNS',
|
||||||
|
'createDynamicDNS',
|
||||||
|
'setDynamicDNS',
|
||||||
'getPortConfig',
|
'getPortConfig',
|
||||||
'getVoipExtensions',
|
'getVoipExtensions',
|
||||||
'getSiteSettings',
|
'getSiteSettings',
|
||||||
'adoptDevice',
|
'adoptDevice',
|
||||||
'rebootAccessPoint',
|
'restartDevice',
|
||||||
|
'forceProvision',
|
||||||
|
'rebootCloudKey',
|
||||||
'disableAccessPoint',
|
'disableAccessPoint',
|
||||||
'setLEDOverride',
|
'setLEDOverride',
|
||||||
'setLocateAccessPoint',
|
'setLocateAccessPoint',
|
||||||
'setSiteLEDs',
|
'setSiteLEDs',
|
||||||
'setAccessPointRadioSettings',
|
'setAccessPointRadioSettings',
|
||||||
|
'setAccessPointWLanGroup',
|
||||||
'setGuestLoginSettings',
|
'setGuestLoginSettings',
|
||||||
|
'setGuestLoginSettingsBase',
|
||||||
|
'setIPSSettingsBase',
|
||||||
|
'setSuperMgmtSettingsBase',
|
||||||
|
'setSuperSMTPSettingsBase',
|
||||||
|
'setSuperIdentitySettingsBase',
|
||||||
'renameAccessPoint',
|
'renameAccessPoint',
|
||||||
|
'moveDevice',
|
||||||
|
'deleteDevice',
|
||||||
|
'getNetworkConf',
|
||||||
|
'createNetwork',
|
||||||
|
'setNetworkSettingsBase',
|
||||||
|
'deleteNetwork',
|
||||||
|
'getWLanSettings',
|
||||||
'createWLan',
|
'createWLan',
|
||||||
'deleteWLan',
|
'setWLanSettingsBase',
|
||||||
'setWLanSettings',
|
'setWLanSettings',
|
||||||
'disableWLan',
|
'disableWLan',
|
||||||
|
'deleteWLan',
|
||||||
|
'setWLanMacFilter',
|
||||||
'getEvents',
|
'getEvents',
|
||||||
'getWLanSettings',
|
|
||||||
'getAlarms',
|
'getAlarms',
|
||||||
|
'countAlarms',
|
||||||
|
'archiveAlarms',
|
||||||
'upgradeDevice',
|
'upgradeDevice',
|
||||||
'upgradeDeviceExternal',
|
'upgradeDeviceExternal',
|
||||||
|
'startRollingUpgrade',
|
||||||
|
'cancelRollingUpgrade',
|
||||||
|
'getFirmware',
|
||||||
|
'powerCycleSwitchPort',
|
||||||
'runSpectrumScan',
|
'runSpectrumScan',
|
||||||
|
'runSpeedTest',
|
||||||
|
'getSpeedTestStatus',
|
||||||
'getSpectrumScanState',
|
'getSpectrumScanState',
|
||||||
|
'setDeviceSettingsBase',
|
||||||
|
'listRadiusProfiles',
|
||||||
'listRadiusAccounts',
|
'listRadiusAccounts',
|
||||||
'createBackup',
|
'createRadiusAccount',
|
||||||
'upgradeExternalFirmware'
|
'setRadiusAccountBase',
|
||||||
|
'deleteRadiusAccount',
|
||||||
|
'cmdStat',
|
||||||
|
'setElementAdoption',
|
||||||
|
'upgradeExternalFirmware',
|
||||||
|
'customApiRequest'
|
||||||
]
|
]
|
||||||
|
|
||||||
const controller = {}
|
const controller = {}
|
||||||
|
|
||||||
for (let key of keys) {
|
for (let key of usedControllerMethods)
|
||||||
controller[key] = promisify(unifiController[key])
|
controller[key] = promisify(unifiController[key])
|
||||||
}
|
|
||||||
|
|
||||||
export { controller }
|
export { controller }
|
||||||
|
|
|
@ -13,8 +13,6 @@ async function getOnlineWifiDevices() {
|
||||||
onlineDevicesPromise
|
onlineDevicesPromise
|
||||||
])
|
])
|
||||||
|
|
||||||
controller.logout()
|
|
||||||
|
|
||||||
const onlineDevicesWithUser = onlineDevices[0].map(client => ({
|
const onlineDevicesWithUser = onlineDevices[0].map(client => ({
|
||||||
user: client['1x_identity'] || null,
|
user: client['1x_identity'] || null,
|
||||||
oui: client.oui,
|
oui: client.oui,
|
||||||
|
@ -29,6 +27,8 @@ async function getOnlineWifiDevices() {
|
||||||
status: 'ONLINE'
|
status: 'ONLINE'
|
||||||
}))
|
}))
|
||||||
|
|
||||||
|
controller.logout()
|
||||||
|
|
||||||
return onlineDevicesWithUser
|
return onlineDevicesWithUser
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
throw new Error('Erro ao listar dispositivos. ' + e)
|
throw new Error('Erro ao listar dispositivos. ' + e)
|
||||||
|
|
Loading…
Reference in New Issue
Block a user