Git Product home page Git Product logo

freeboxphp's Introduction

FreeBox PHP

Packagist Version Actions Status codecov

This is a small and simple PHP library to interface with Iliad FreeBox (IliadBox for the Italian market) provided broadband routers.

Install

Using composer:

composer require madpilot78/FreeBoxPHP

Requirements

This project works with PHP 8.3 and upper.

Library description

I'm writing this library for my own needs. It handles discovery and authentication and then exposes some router APIs via methods.

For a list of implemented methods look in src/Methods.

NOTE: Since I'm in Italy I have tested this only with my router, an IliadBox (Italian version), configured with self provided certificate. If you have a different setup and have problems, please contact me and maybe I can update the library to work with more setups.

NOTE

For documentation on each API specifics please check your OpenBox/IliadBox developer documentation, accessible through the WebUI.

How to use

There is a Configuration object that can be used to customize the library.

First one needs to register with the Box, for example:

use madpilot78\FreeBoxPHP\Configuration;
use madpilot78\FreeBoxPHP\Box;
use madpilot78\FreeBoxPHP\Enum\BoxType;

$config = new Configuration(
    hostname: 'box.example.org',
    boxType: BoxType::Iliad,
    certFile: null,
);

$box = new Box(configuration: $config);

$token = $box->discover()->register(quiet: false);

echo $token . PHP_EOL;

(check the FreeBox/IliadBox display to authorize the client)

Once the client ha been authorized its permissions can be configured in the FreeBox/IliadBox UI.

With the token it is possible to access the full functionality.

For example to display IPv6 configuration:

use madpilot78\FreeBoxPHP\Configuration;
use madpilot78\FreeBoxPHP\Box;
use madpilot78\FreeBoxPHP\Enum\BoxType;

$config = new Configuration(
    hostname: 'box.example.org',
    boxType: BoxType::Iliad,
    certFile: null,
);

$box = new Box(authToken: '<token>', configuration: $config);

$ret = $box->discover()->connectionIPv6Configuration('get');

var_dump($ret);

(NOTE: discover() needs to be called only once per instance, results are cached in the instance)

The IPv6 firewall can be turned on with (this API will also return the new configuration):

$ret = $box->connectionIPv6Configuration(set', ['ipv6_firewall' => true]);

var_dump($ret);

APIs requiring an ID take it as an argument, for example to fetch an existing redirect:

$ret = $box->fwRedir('get', 1));

var_dump($ret);

And a disable redirect can be modified (for example enabled) like this:

$ret = $box->fwRedir('update', 1, ['enabled' => true]));

var_dump($ret);

Implemented APIs

  • Discover
  • Register
  • Login/Logout (login performed automatically if needed)
  • Language (changing the language may not work, I suspect this is a restriction on my IliadBox)
  • ConnectionConfiguration
  • ConnectionIPv6Configuration
  • ConnectionStatus (r/o)

freeboxphp's People

Contributors

dependabot[bot] avatar madpilot78 avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.