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