WARNING: Work In Progress.
This gem contains Freebox OS API bindings for the Ruby language. I started working on that to use it with https://github.com/mcanevet/puppet-freebox.
The official documentation is located here: http://dev.freebox.fr/sdk/os/
require 'freebox_api'
myFreebox = FreeboxApi::Freebox.new
or
require 'freebox_api'
myFreebox = FreeboxApi::Freebox.new({
:freebox_ip => 'mafreebox.example.com',
:freebox_port => 4242,
})
This is the first step, the app will ask for an app_token using the following call. A message will be displayed on the Freebox LCD asking the user to grant/deny access to the requesting app.
Once the app has obtained a valid app_token, it will not have to do this procedure again unless the user revokes the app_token.
token_request = {
:app_id => 'fr.freebox.testapp',
:app_name => 'Test App',
:app_version => '0.0.7',
:device_name => 'Pc de Xavier'
}
auth_request = myFreebox.authorize(token_request)
app_token = auth_request['app_token']
myApp = {
:app_id => 'fr.freebox.testapp',
:app_version => '0.0.7',
:app_token => 'dyNYgfK0Ya6FWGqq83sBHa7TwzWo+pg4fDFUJHShcjVYzTfaRrZzm93p7OTAfH/0',
}
mySession = FreeboxApi::Session.new(myApp, myFreebox)
or
mySession = FreeboxApi::Session.new({
:app_id => 'fr.freebox.testapp',
:app_version => '0.0.7',
:app_token => 'dyNYgfK0Ya6FWGqq83sBHa7TwzWo+pg4fDFUJHShcjVYzTfaRrZzm93p7OTAfH/0',
}, FreeboxApi::Freebox.new)
FreeboxApi::Configuration::Connection.getStatus(mySession)
FreeboxApi::Configuration::Connection.getConfig(mySession)
FreeboxApi::Configuration::Connection.updateConfig(mySession, {
:ping => true,
:wol => false,
})
FreeboxApi::Configuration::Connection::IPv6.getConfig(mySession)
FreeboxApi::Configuration::Connection::IPv6.updateConfig(mySession, {
:delegations => [
{
:prefix => '2a01:e30:d252:a2a2::/64',
:next_hop => 'fe80::be30:5bff:feb5:fcc7',
}
]
})
FreeboxApi::Configuration::Connection::DDNS.getStatus(mySession, 'dyndns')
or
ddns = FreeboxApi::Configuration::Connection::DDNS.new(mySession, 'dyndns')
ddns.status
FreeboxApi::Configuration::Connection::DDNS.getConfig(mySession, 'dyndns')
or
ddns = FreeboxApi::Configuration::Connection::DDNS.new(mySession, 'dyndns')
ddns.config
FreeboxApi::Configuration::Connection::DDNS.updateConfig(mySession, 'dyndns', {
:enabled => false,
:user => 'test',
:password => 'ssss',
:hostname => 'ttt',
})
or
ddns = FreeboxApi::Configuration::Connection::DDNS.new(mySession, 'dyndns')
ddns.config = {
:enabled => false,
:user => 'test',
:password => 'ssss',
:hostname => 'ttt',
}
FreeboxApi::Configuration::Lan.getConfig(mySession)
FreeboxApi::Configuration::Lan.updateConfig({
:mode => 'router',
:ip => '192.168.69.254',
:name => 'Freebox de r0ro',
:name_dns => 'freebox-de-r0ro',
:name_mdns => 'Freebox-de-r0ro',
:name_netbios => 'Freebox_de_r0ro',
})
FreeboxApi::Configuration::Lan::Browser.interfaces(mySession)
FreeboxApi::Configuration::Lan::Browser::Interface.getLanHosts(mySession, 'pub')
interface = FreeboxApi::Configuration::Lan::Browser::Interface.new(mySession, 'pub')
interface.lan_hosts
FreeboxApi::Configuration::Lan::Browser::LanHost.show(mySession, 'pub', 'ether-00:24:d4:7e:00:4c')
or
lan_host = FreeboxApi::Configuration::Lan::Browser::LanHost.new(mySession, 'pub', 'ether-00:24:d4:7e:00:4c')
lan_host.show
FreeboxApi::Configuration::Lan::Browser::LanHost.update(mySession, 'pub', 'ether-00:24:d4:7e:00:4c', {
:id => 'ether-00:24:d4:7e:00:4c',
:primary_name => 'Freebox Tv',
})
or
lan_host = FreeboxApi::Configuration::Lan::Browser::LanHost.new(mySession, 'pub', 'ether-00:24:d4:7e:00:4c')
lan_host.update({
:id => 'ether-00:24:d4:7e:00:4c',
:primary_name => 'Freebox Tv',
})
FreeboxApi::Configuration::Lan::Browser::Interface.wol(mySession, 'pub', {
:mac => '00:24:d4:7e:00:4c',
:password => '',
}
or
interface = FreeboxApi::Configuration::Lan::Browser::Interface.new(mySession, 'pub')
interface.wol({
:mac => '00:24:d4:7e:00:4c',
:password => '',
}
or
lan_host = FreeboxApi::Configuration::Lan::Browser::LanHost.new(mySession, 'pub', 'ether-00:24:d4:7e:00:4c')
lan_host.wol({ :password => '' })
FreeboxApi::Configuration::Freeplug.network(mySession)
FreeboxApi::Configuration::Freeplug.show(mySession, 'F4:CA:E5:1D:46:AE')
or
freeplug = FreeboxApi::Configuration::Freeplug.new(mySession, 'F4:CA:E5:1D:46:AE')
freeplug.show
FreeboxApi::Configuration::Freeplug.reset(mySession, 'F4:CA:E5:1D:46:AE')
or
freeplug = FreeboxApi::Configuration::Freeplug.new(mySession, 'F4:CA:E5:1D:46:AE')
freeplug.reset
FreeboxApi::Configuration::Dhcp.getConfig(mySession)
FreeboxApi::Configuration::Dhcp.updateConfig(mySession, {
:enabled => false,
})
FreeboxApi::Configuration::Dhcp.static_leases(mySession)
FreeboxApi::Configuration::Dhcp::StaticLease.show(mySession, '00:DE:AD:B0:0B:55')
or
static_lease = FreeboxApi::Configuration::Dhcp::StaticLease.new(mySession, '00:DE:AD:B0:0B:55')
static_lease.show
FreeboxApi::Configuration::Dhcp::StaticLease.update(mySession, {
:id => '00:DE:AD:B0:0B:55',
:comment => 'Mon PC',
})
or
static_lease = FreeboxApi::Configuration::Dhcp::StaticLease.new(mySession, '00:DE:AD:B0:0B:55')
static_lease.update({
:id => '00:DE:AD:B0:0B:55',
:comment => 'Mon PC',
})
FreeboxApi::Configuration::Dhcp::StaticLease.delete(mySession, '00:DE:AD:B0:0B:55')
or
static_lease = FreeboxApi::Configuration::Dhcp::StaticLease.new(mySession, '00:DE:AD:B0:0B:55')
static_lease.delete
FreeboxApi::Configuration::Dhcp::StaticLease.create(mySession, {
:ip => '192.168.1.222',
:mac => '00:00:00:11:11:11',
})
or
static_lease = FreeboxApi::Configuration::Dhcp::StaticLease.new(mySession, '00:00:00:11:11:11')
static_lease.create({
:ip => '192.168.1.222',
:mac => '00:00:00:11:11:11',
})
FreeboxApi::Configuration::Dhcp.dynamic_leases(mySession)
FreeboxApi::Configuration::Ftp.getConfig(mySession)
FreeboxApi::Configuration::Ftp.updateConfig(mySession, {
:enabled => true,
})
FreeboxApi::Configuration::Nat::Dmz.getConfig(mySession)
FreeboxApi::Configuration::Nat::Dmz.updateConfig(mySession, {
:enabled => true,
:ip => '192.168.1.42',
})
FreeboxApi::Configuration::Nat.port_forwardings(mySession)
FreeboxApi::Configuration::Nat::PortForwarding.show(mySession, 1)
###### Updating a port forwarding
FreeboxApi::Configuration::Nat::PortForwarding.update(mySession, 1, {
:enabled => false,
})
FreeboxApi::Configuration::Nat::PortForwarding.create(mySession, {
:enabled => true,
:comment => 'test',
:lan_port => 4242,
:wan_port_end => 4242,
:wan_port_start => 4242,
:lan_ip => '192.168.1.42',
:ip_proto => 'tcp',
:src_ip => '0.0.0.0',
})
FreeboxApi::Configuration::Nat::PortForwarding.delete(mySession, 3)