Skip to content

Commit

Permalink
Merge branch 'release/0.1.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
unknownskl committed Jun 15, 2018
2 parents 225518a + 4161af1 commit fd61b5a
Show file tree
Hide file tree
Showing 15 changed files with 801 additions and 0 deletions.
17 changes: 17 additions & 0 deletions .codeclimate.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
engines:
eslint:
enabled: true
duplication:
enabled: true
config:
languages:
javascript:
mass_threshold: 65
shellcheck:
enabled: true
checks:
method-count:
enabled: false
ratings:
paths:
- "*.js"
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
node_modules
14 changes: 14 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
FROM node:9-alpine

WORKDIR /app

RUN apk add python make g++ --update

ADD package.json ./
RUN npm install

ADD src ./src
ADD bin ./bin
RUN npm link

ENTRYPOINT [ "node", "bin/client.js" ]
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
The MIT License (MIT)

Copyright (c) 2016 UnknownSKL (Jim Kroon)

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
14 changes: 14 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
run: build
docker run xbox-smartglass-core-node

run_discovery: build
docker run xbox-smartglass-core-node -d

run_boot: build
docker run xbox-smartglass-core-node -b -i 127.0.0.1 -l FD000000000000

run_help: build
docker run xbox-smartglass-core-node --help

build:
docker build -t xbox-smartglass-core-node .
45 changes: 45 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,48 @@
# Xbox-Smartglass-Core-Node

NodeJS smartglass library for controlling a Xbox

## Dependencies

- NodeJS 9 (X509 package is not compatible with Node 10 yet)
- NPM

## How to install

```npm install xbox-smartglass-core-node --save```

## How to use

### Boot the Xbox console

```
Smartglass.power_on({
live_id: 'FD000000000000', // Put your console's live id here (Required)
tries: 4, // Number of packets too issue the boot command (Optional)
ip: '127.0.0.1' // Your consoles ip address (Optional)
}, function(result){
if(result)
console.log('Device booted successfully');
else
console.log('Failed to boot device');
});
```

### Discover consoles on network

```
Smartglass.discovery({
ip: '127.0.0.1' // Your consoles ip address (Optional)
}, function(device, address){
console.log('- Device found: ' + device.device_name);
console.log('Address: '+ address.address + ':' + address.port);
console.log('LiveID: ' + device.device_certificate.subject.commonName);
console.log('Certificate valid: ' + device.device_certificate.notBefore + ' - ' + device.device_certificate.notAfter);
console.log('Certificate fingerprint: ' + device.device_certificate.fingerPrint);
});
```

## Known Issues

- Broadcasting does not work properly yet
- Callback when sending a power_on command always returns true for now.
55 changes: 55 additions & 0 deletions bin/client.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
#!/usr/bin/env node
var Smartglass = require('../src/smartglass');
var commander = require('commander');
var assert = require('assert');
var pkgInfo = require('../package.json');

const ADDR_BROADCAST = '255.255.255.255';

console.log('Xbox-Smartglass v'+pkgInfo['version']+' ('+pkgInfo['homepage']+')');

commander
.usage('[-b -d -s] -i <ip_address> -l <live_device_id> [-t <tries>]')
.option('-b, --boot', 'Boot Xbox console')
.option('-d, --discover', 'Discover Xbox on the network')
//.option('-s, --shutdown', 'Shutdown Xbox console')
.option('-i, --ip <ip>', 'Xbox One IP address', ADDR_BROADCAST)
.option('-l, --live_id <live_id>', 'Xbox One live id (Example: FD000000000000)')
.option('-t, --tries <tries>', 'Timeout inn seconds (Default: 4)', 4)
.version(pkgInfo['version'])
.parse(process.argv);

if(process.argv.length <= 2)
commander.help();

if(commander.boot == true)
{
if(commander.live_id == undefined)
console.error('--live_id parameter required');
else {
console.log('Trying to boot device...');
Smartglass.power_on({
live_id: commander.live_id,
tries: commander.tries,
ip: commander.ip
}, function(result){
if(result)
console.log('Device booted successfully');
else
console.log('Failed to boot device');
});
}

} else if(commander.discover)
{
console.log('Trying to discover devices...');
Smartglass.discovery({
ip: commander.ip
}, function(device, address){
console.log('- Device found: ' + device.device_name);
console.log('Address: '+ address.address + ':' + address.port);
console.log('LiveID: ' + device.device_certificate.subject.commonName);
console.log('Certificate valid: ' + device.device_certificate.notBefore + ' - ' + device.device_certificate.notAfter);
console.log('Certificate fingerprint: ' + device.device_certificate.fingerPrint);
});
}
185 changes: 185 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

32 changes: 32 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
{
"name": "xbox-smartglass-core-node",
"version": "0.1.0",
"description": "NodeJS smartglass library for controlling a Xbox",
"main": "index.js",
"scripts": {
"test": "./node_modules/mocha/bin/mocha tests/"
},
"repository": {
"type": "git",
"url": "[email protected]:unknownskl/xbox-smartglass-core-node.git"
},
"author": "UnknownSKL (Jim Kroon)",
"license": "MIT",
"bin": {
"smartglass-client": "./bin/client.js"
},
"bugs": {
"url": "https://github.com/unknownskl/xbox-smartglass-core-node/issues"
},
"homepage": "https://github.com/unknownskl/xbox-smartglass-core-node",
"keywords": [
"xbox",
"xbox one",
"smartglass"
],
"dependencies": {
"commander": "^2.15.1",
"mocha": "^5.2.0",
"x509": "^0.3.3"
}
}
Loading

0 comments on commit fd61b5a

Please sign in to comment.