Giter Site home page Giter Site logo

blacksenator / fbcallrouter Goto Github PK

View Code? Open in Web Editor NEW
31.0 8.0 4.0 172 KB

Spamfilter for FRITZ!Box listen to call monitor as background service

License: MIT License

PHP 98.56% Dockerfile 1.44%
avm spam-filtering tellows callmonitor soap tr-064 fritzbox

fbcallrouter's Introduction

An extended call routing for AVM FRITZ!Box

The program is trying to identify spam calls. So it is listen to the FRITZ!Box call monitor and does several wash cycles to figure out whether it is spam or not.

Please remember to update the master data regularly so that the program works correctly!

Release notes

If you already use an older version please refer to the update section and be aware that the structure of the configuration file differ (see config.example.php).

Preconditions

  • the program only works in the German telephone network!
  • you use a Fritz!Box for landline telephoning
  • you need to have a separate spam phone book beside your phone book!
  • you have a microcomputer (e.g. Raspberry Pi) running 24/7 in your network

Description

For an incoming call a cascaded check takes place:

  • First, it is checked, whether the number is already known in your telephone books ('whitelist') and ('blacklist') or ('newlist'). This also includes central numbers used, whose various extensions are defined with '*' in the phone book. Of course, all these known telephone numbers are not analyzed any further.

  • If unknown, it is checked if it is a foreign number. If you have set ('blockForeign') the number will be direct transferred to the corresponding phone book ('blacklist') for future rejections. If not, then foreign numbers are

    • screened to see whether they exceed or fall short of the expected lengths,
    • whether they transmit country codes that are not (or no longer) used or
    • if area code starts with invalid "0" (zero).
  • The following screenings are carried out for domestic numbers, which are essentially aimed at "CLIP - no screening":

    • transmission of a unvalid area code ONB or cellular code
    • unvalid subscribers number, if a landline number starts with an zero
    • concealment of a mobile phone number using a prefix consisting of your own area code and country code,
    • transmission of the actual phone number in brackets after a user provided number and
    • falling below or exceeding expected lengths.
  • If all this passed, it is checked at various scoring sites (currently five: WERRUFT, Clever Dialer, Telefonspion, WerHatAngerufen and tellows), if this number has received a bad online rating. If this is the case, the number - also as with pattern errors - is included in the blacklist.

  • Finally, of course, there is the possibility that the caller is known in a positive sense and can be identified via a public telephone book (Das Örtliche). Then he/she/it is optionally entered in a dedicated phone book ('newlist') with the determined name. This feature is also used for outgoing calls to unknown numbers!

  • In addition, the program offers the option of being informed about unknown incoming (and outgoing) phone numbers by email. In particular, the information on the extent to which the caller could be identified and possibly added to one of the telephone books is convinient without having to be able to trace this using the caller list in the FRITZ!Box or in the logging file.

Requirements

  • PHP >= 7.3 (php-cli, php-curl, php-mbstring, php-soap, php-xml)
  • call monitor (port 1012) is open - if not: dial #96*5* to open it
  • Composer (follow the installation guide)

Installation

Programm

Install requirements are:

git clone https://github.com/blacksenator/fbcallrouter.git
cd fbcallrouter

Install composer (see https://getcomposer.org/download/ for newer instructions):

composer install --no-dev

Edit the config.example.php and save as config.php or use an other name of your choice (but than keep in mind to use the -c option to define your renamed file)

Preconditions on the FRITZ!Box

Phone book for rejections (bad apples)

If you do not have your own phone book for spam numbers, it is essential to add a new one (e.g. "Spamnummern"). Note that the first phone book ("Telefonbuch") has the index "0" and the numbers are ascending according to the index tabs. Then you have to link this phone book for call handling.

Phone book for trustworthy new numbers

If you want to add previously unknown but trustworthy umbers as contacts, you can do this optionally: e.g. in a separate phone book that you have created in the FRITZ!Box. However, you can also have these additions added to your standard telephone book..

FRITZ!Box user

The programm accessed the Fritz!Box via TR-064. Make sure that the user you choose in configuration (see next topic) is granted for this interface. The user needs authorization for "voice messages, fax messages, FRITZ!App Fon and the call list"!

Configuration

The configuration file (default config.php) offers various customization options. For example: Adapted to the tellows rating model a bad score is determined as six to nine and needs at least more than three comments. The second parameter is for quality purposes: not a single opinion should block a service provider whose call you might expect. You can adapt the values in the configuration file. But be carefull! If you choose score values equal or smaler then five (5), than numbers with impeccable reputation where written to your rejection list! Because the rating websites use different scales, they are normalized to the tellows scale.

If you set 'log' in your configuration and the 'logPath' is valid, the essential process steps for verification are written to the log file callrouter_logging.txt. If 'logPath' is empty the programm directory is default.

Usage

As mentioned, the program is designed to run permanently in the background. In order to ensure this, it is necessary to make sure that this is possible without interruption and should be tested accordingly.

Test

It is highly recommended test the setting by following the next steps:

1. Function test

php fbcallrouter run

If On guard... appears, the program is armed.

Make a function test in which you call your landline from your cell phone: your mobile phone number should not end up in the spam phone book! If the number is in your phone book, nothing should happen anyway (on whitelist). Otherwise: your mobile phone number is not a foreign number, the ONB/RNB is correct and you certainly do not have a bad entry in online directories. Therefore these tests should not lead to any sorting out. Press CTRL+C to terminate the programm.

If logging is enabled (which is highly recommended for this test), than nano callrouter_logging.txt will show you what happend at the call monitor interface.

2. Integration test

There are five exemplary 'numbers' stored in the configuration file with which you can test the wash cycles integratively. You can change these test numbers according to your own ideas and quantity. Starting the programm with the -t option, these numbers will be injected as substitutes one after the other for the next calls the FRITZ!Box receives and its call monitor port will broadcast.

It is highly recommended to proceed like this:

  1. check if none of the substitutes are already in your phone book! Especially if you repeat the test!

  2. if you want to a web query, make crosscheck at the named providers that the choosen test phone number(s) actually has/ve the desired score and comments!

  3. start the programm

    php fbcallrouter run -t
  4. use your cellular phone to call your landline. The incoming mobil number will be replaced with the first/next number from this array and passes through the inspection process. Additional information is output like this:

    Starting FRITZ!Box call router...
    On guard...
    Running test case 1/5
  5. let it ring at least twice before hanging up. Repeat calling from your cellular your landline number. So you have to call as many times as there are numbers in the array to check all test cases (or quit programm execution with CTRL+C). The program then ends this number replacement.

  6. check the blacklist phone book whether all numbers have been entered as expected. If logging is enabled, than nano callrouter_logging.txt will show you what happend. If e-mail notification is choosen check your inbox. To cancel, press CTRL+C.

3. Permanent background processing

The main concept of this tool is to continuously check incoming calls. Therefore it should ideally run permanently as a background process on a single-board computer (e.g. Raspberry Pi) in the home network. A corresponding definition file is prepared: fbcallrouter.service

  1. edit [youruser] in this file with your device user (e.g. pi) and save the file

    nano fbcallrouter.service
  2. copy the file into /etc/systemd/system

    sudo cp fbcallrouter.service /etc/systemd/system/fbcallrouter.service
  3. enable the service unit:

    sudo systemctl enable fbcallrouter.service
  4. check the status:

    sudo systemctl status fbcallrouter.service

Update

As noted at the beginning, functional enhancements usually go hand in hand with additions to the configuration file. To install the current version, please proceed as follows:

  1. change to the installation directory:

    cd /home/[youruser]/fbcallrouter
  2. stop the service:

    sudo systemctl stop fbcallrouter.service
  3. delete the old logging file (if you used it here):

    rm callrouter_logging.txt
  4. get the latest version from:

    git pull https://github.com/blacksenator/fbcallrouter.git
  5. bring all used libraries up to date:

    composer update --no-dev
  6. check for changes in the configuration file...

    nano config.example.php
  7. ...and eventually make necessary changes/additions in your configuration:

    nano config.example.php
  8. restart the service...

    sudo systemctl start fbcallrouter.service
  9. ...and wait few seconds before you check if the service is running:

    sudo systemctl status fbcallrouter.service

Master data

ONB

ONB = OrtsNetzBereiche (Vorwahlbereiche/Vorwahlen). The list used comes from the BNetzA and should be valid for a limited period of time. If you want to update them, then download the offered CSV file Vorwahlverzeichnis. Unpack the archive and save the file as ONB.csv in the ./assets directory.

RNB

RNB = numbers for mobile services. The BNetzA do not provide a list for download with cellular codes (RNB). The currently used ones were transferred to the ./assets directory as $cellularNumber in cellular.php.

Country codes

The currently used ones were transferred to the ./assets directory as $countryCode in countrycode.php. The list was mainly compiled from information from wikipedia.

Does the programm works propperly? Troubleshooting

First of all: of course the program can contain bugs and not work as expected. If you are convinced, please open an issue here. In addition, it can of course be more due to the selected settings for the configuration of the filter.

Last but not least I myself have made some observations that led me to suspect that the program would not work correctly. In principle, it is advisable in such cases to switch on logging ('log' => true,) or to compare the active logging with the call list of the FRITZ!Box. You may need to go a step further and correlate dates with reverse search sites.

An example: I had calls that should have been identified as spam at first glance through web research. A closer look showed that this spammer only appeared in the lists at exactly that time and had not yet received a sufficient number of negative comments at the time of the call.

Privacy

No private data from this software will be passed on to third parties accepts with this exception: when using

the incoming number is transmitted to the provider. Their data protection information must be observed!

Feedback

If you enjoy this software, then I would be happy to receive your feedback, also in the form of user comments and descriptions of your experiences, e.g. in the IP Phone Forum. This puts the user community on a broader basis and their experiences and functional ideas can be incorporated into further development. In the end, these features will benefit everyone.

Improvements

As ever, this program started with only a few lines of code just to play with the call monitor interface provided and to figure out how it works...

...than more and more ideas came to my mind how this interface could solve some of my needs.

As I have already written in the fritzsoap documentation, it would be an enormous relief if AVM would provide functionality to terminate incoming calls, just as FRITZ!OS itself does it with the handling of phone numbers to be blocked. The entry of more and more numbers in corresponding blacklists could be omitted or reduced.

Disclaimer

FRITZ!Box, FRITZ!fon, FRITZ!OS are trademarks of AVM. This software is in no way affiliated with AVM and only uses the interfaces published by them.

License

This script is released under MIT license.

Author

Copyright© 2019 - 2024 Volker Püschel

fbcallrouter's People

Contributors

blacksenator avatar ihavenoface avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

fbcallrouter's Issues

Failed to request - Phone not ringing

Logentry:

16.06.2023 10:53:47 => CALL IN from number 0041584xxx to MSN 471xxx
16.06.2023 10:53:48 => Request in spam databases failed!

What can be the cause? The Number calling is from a company in swizerland and i know it be no spam

feature request: Führende Zahlen, die automatisch im SPAM landen

Ich habe festgestellt, dass ich erstaunlich viele SPAM-Anrufe erhalte, die immer dieselbe Vorwahl tragen:

  • 01521 4094105
  • 01521 7871549
  • 01521 0467468
  • 01521 7595144

...

Auch auf die Gefahr ein paar false negative zu erhalten: wäre es sinnvoll, den Filter um solche "Vorwahlen" zu ergänzen?
Bei mir laufen alle SPAM-Anrufe sofort auf einen eigenen SPAM-Anrufbeantworter auf dem ich erkläre, der Anruf ist im SPAM-Filter gelandet und wer meint, das sei falsch, solle drauf sprechen. Ich habe bisher nur vier AB-Nachrichten von drölfzig solchen Anrufen erhalten. Alle waren automatische Bandansagen der üblichen "Sie haben gewonnen, drücken sie 1"... Masche. von daher können da gern die false positiven draufsprechen, dass sie mich sprechen wollen.

Feature Request: Auch bei positiven Bewertungen die Rückwärtssuche starten, wenn newlist aktiv

Ich habe gerade den Fall, dass eine unbekannte Telefonnummer angerufen hat:

  1. Rating 5 bei 0 Kommentaren bei tellows
  2. Der Anruf wurde angenommen
  3. keine weitere Prüfung

In diesem Fall hätte ich aber gerne die Telefonnummer in dem von mir angegebenen "Newlist"-Telefonbuch bekommen, d.h.

  1. Rating 5 bei 0 Kommentaren bei tellows
  2. Der Anruf wurde angenommen
  3. weitere Prüfung: Ist die Telefonnummer in der Rückwärtssuche enthalten
  4. wenn Telefonnummer gefunden wird: Eintrag in newlist

Damit wäre die Telefonnummer mit gefundenem Namen dann auch im Display bei (künftigen?) Anrufen - und muss nicht mehr geprüft werden, wenn das newlist-Telefonbuch in der Whitelist-Liste aufgeführt ist.

Feature Request: Mailversand, wenn eine Nummer Rejected wurde

Ich hätte gerne eine Nachricht (am besten per Email), wenn eine Nummer abgelehnt wurde mit folgendem Inhalt:

  • Angerufene MSN
  • Nummer des Anrufers
  • Grund der Ablehnung
  • ggf. weitere Aktionen
  • Uhrzeit

Es reicht also, wenn die Infos, die bisher pro Anruf geloggt werden per Email verschickt werden:

10.11.2022 17:02:18 => CALL IN from number 03887442441 to MSN 123456789
10.11.2022 17:02:19 => Caller has a bad reputation (8/29)! Added to spam phonebook #1

am geilsten wäre zusätzlich auch ein Deep-Link in der EMail auf den Dienst, der dafür verantwortlich war, also z.B. im konkreten Fall: https://www.tellows.de/num/03887442441 und auch beim "Örtlichen"-Fund: https://www.dasoertliche.de/rueckwaertssuche/?ph=089353510

Validation of outgooing Calls from a (Mesh) client friztbox

Hello,
first of all thanks for the great program, I have been using fbcallrouter for a few days now and hope to get the annoying calls under control.
I have a second Fritzbox integrated in my network as a Mesch client. The telephony functions (outgoing numbers and phone books) are taken over and synchronized by the master Fritzbox. Only the registered telephones have to be permanently assigned to a box.
If you make an outgoing call from a telephone connected to the client box, the outgoing number is registered in fbcallrouter with a "#" at the end. Known telephone numbers of outgoing calls are then no longer recognized by fbcallrouter, even if they have been saved correctly in the telephone book.
Outgoing calls from telephones connected to the Maser-Box are unproblematic, here the telephone numbers are determined without the annoying "#" character.
As a workaround, I have added the function "runOutboundValidation" to the file "callrouter.php" as follows:
public function runOutboundValidation()
{
if ($this->isMSNtoProof($this->callMonitorValues['intern'])) {
$number = $this->callMonitorValues['extern'];
// Edit Begin
if (strrpos($number,'#') == strlen($number)-1) {
$number = substr($number, 0, -1);
}
// Edit Ende
$message = $this->setLogging(12, [$number]);
if ($this->isNumberKnown($number) === false) {
$this->mailNotify = false;
$this->mailText[] = $message;
......
Perhaps you can incorporate this into your code or solve it more "elegantly".


Hallo,
zunächst einmal vielen Dank für das tolle Programm, ich benutze fbcallrouter seit ein paar Tagen und hoffe, die lästigen Anrufe in den Griff zu bekommen.
Ich habe eine zweite Fritzbox als Mesch-Client in mein Netzwerk eingebunden. Die Telefonie-Funktionen (ausgehende Nummern und Telefonbücher) werden von der Master-Fritzbox übernommen und synchronisiert. Nur die angemeldeten Telefone müssen einer Box fest zugewiesen werden.
Wird von einem an der Client-Box angeschlossenen Telefon ein ausgehender Anruf getätigt, wird die ausgehende Nummer im fbcallrouter mit einem "#" am Ende registriert. Bekannte Telefonnummern von ausgehenden Anrufen werden dann von fbcallrouter nicht mehr erkannt, auch wenn sie korrekt im Telefonbuch gespeichert wurden.
Unproblematisch sind ausgehende Anrufe von an der Maser-Box angeschlossenen Telefonen, hier werden die Telefonnummern ohne das störende "#"-Zeichen ermittelt.
Als Workaround habe ich die Funktion "runOutboundValidation" in der Datei "callrouter.php" wie oben geändert
Vielleicht können Sie dies in Ihren Code einbauen oder das Problem "eleganter" lösen.

Viele Grüße
MKamaro

Fehlende Datei assets/celluar.php

Hallo,

beim Start der Anwendung wird folgender Fehler gemeldet.

Fehler:

php fbcallrouter run -t
Starting FRITZ!Box call router...
PHP Warning:  require_once(assets/celluar.php): failed to open stream: No such file or directory in /home/fbcallrouter/fbcallrouter/src/callrouter/callrouter.php on line 272
PHP Fatal error:  require_once(): Failed opening required 'assets/celluar.php' (include_path='.:/usr/share/php') in /home/fbcallrouter/fbcallrouter/src/callrouter/callrouter.php on line 272

Info:

commit 990a1e4709caaf1965e3f18bc5d113a2e292433a (HEAD -> master, tag: v2.4, origin/master, origin/HEAD)
Author: Black Senator <[email protected]>
Date:   Sun Apr 11 23:30:25 2021 +0200

    complete refactoring


MfG

fgets() expects parameter 1 to be resource, bool given in C:\xampp\htdocs\fbcallrouter\src\functions.php on line 32

Vorweg: bin nicht so der PHP-Fan, eher in Python zu Hause.

Vorweg:
Composer installiert, dies hier wie beschrieben mit composer installiert, config.php angepasst, eine 7490 die nur via IP erreichbar ist (also nicht via fritz.box) soll angesteuert werden. In der php.ini musste ich noch die soap extension aktivieren. Wenn ich nun aufrufe:

php fbcallrouter run

werde ich aber geflutet mit staendig der gleichen Ausgabe:

Warning: fgets() expects parameter 1 to be resource, bool given in C:\xampp\htdocs\fbcallrouter\src\functions.php on line 32
PHP Warning: fgets() expects parameter 1 to be resource, bool given in C:\xampp\htdocs\fbcallrouter\src\functions.php on line 32

Ggf. ist es ja nur was Triviales, wie gesagt, meine Zeit in PHP ist etwas her ;)

Gibt es ggf. einen simplen Aufruf der einfach nur testet, ob die Verbindung mit Fritz klappt?

Adding a new entry to the phonebook - works sometimes only

In der Datei x_contact.php gibt es die Methode setPhonebookEntry..

Ich habe versuchsweise und ganz absichtlich in der "beruehmten" true Loop ganz zu Anfang und absichtlich zweimal hinzugefuegt:

        $callrouter->setContact("TESTCASE2", "0099123456", 'RING', $blacklist);
        $callrouter->setContact("TESTCASE2", "0099123456", 'RING', $blacklist);
        die("DEBUG");

Das Ergebnis war, dass es "meist" mit dem Hinzufuegen ging, sobald ich aber zB einen Debugger einsetze und in setPhonebookEntry einen Breakpoint setze, sehe ich doch oefter dass das $result null ist, oder aber es wird zB nur einer der beiden Eintraege gesetzt (so hatte ich nach 3 Aufrufen teils statt 6 Eintraege 5 im Telefonbuch).

Besonders krass: teilweise, also nur manchmal, bekomme ich geworfen HTTP unauthorized!

Dabei liegt das nicht am verwendeten Benutzer. Wenn es klappte, dann sowohl mit dslf_config als auch einem dediziert neuen Benutzer mit entsprechenden Rechten.

Ich wollte das nur auch nochmal dokumentiert haben. PR erstelle ich bislang keinen, da der Autor wahrscheinlich tiefer in der Materie drinsteckt, und ich mich erst einarbeiten muesste ;)

[Feature request] Add link for searchresult for good numbers

The following results and actions have been recorded:

08.08.2023 15:02:15 => CALL IN from number 0404223602692 to MSN 471033

08.08.2023 15:02:18 => Caller has a rating of 9 out of 9 and 2 valuations.

I miss the link to the search in the web, where i can check the number.

I want to install this on a Raspberry Zero W and can't get any further

Hello !
I want to install this on a Raspberry Zero W and can't get any further

pi@raspberrypi:~/fbcallrouter $ php fbcallrouter run PHP Fatal error: Uncaught Error: Class 'Symfony\Component\Console\Application' not found in /home/pi/fbcallrouter/fbcallrouter:10 Stack trace: #0 {main} thrown in /home/pi/fbcallrouter/fbcallrouter on line 10 pi@raspberrypi:~/fbcallrouter $

fbcallrouter startet nicht

Hallo blacksenator (Sorry for writing in german),
habe deine Installationsanleitung Punkt für Punkt befolgt. Leider startet das Programm nicht. Nach Eingabe von: "php fbcallrouter run" kommt immer:

I followed your installation guide step by step. Unfortunately the program does not start. After entering: "php fbcallrouter run" always shows up:

PHP Fatal error: Uncaught Error: Call to a member function GetPhonebookList() on null in /home/vopi/fbcallrouter/vendor/blacksenator/fritzsoap/src/x_contact.php:253

Stack trace:
#0 /home/vopi/fbcallrouter/src/callrouter/phonetools.php(77): blacksenator\fritzsoap\x_contact->getPhonebookList()
#1 /home/vopi/fbcallrouter/src/callrouter/phonetools.php(63): blacksenator\callrouter\phonetools->getPhoneBookList()
#2 /home/vopi/fbcallrouter/src/callrouter/callrouter.php(75): blacksenator\callrouter\phonetools->__construct(Array)
#3 /home/vopi/fbcallrouter/src/functions.php(16): blacksenator\callrouter\callrouter->__construct(Array, Array)
#4 /home/vopi/fbcallrouter/src/RunCommand.php(32): blacksenator\callRouting(Array, Array)
#5 /home/vopi/fbcallrouter/vendor/symfony/console/Command/Command.php(255): blacksenator\RunCommand->execute(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#6 /home/vopi/fbcallrouter/vendor/symfony/console/Application.php(992): Symfony\Component\Consol in /home/vopi/fbcallrouter/vendor/blacksenator/fritzsoap/src/x_contact.php on line 253

kannst du weiterhelfen?

Gruß Stefan

Beim Testrun einen Fehler erkannt

Erstmal danke für das tolle Tool - verspricht dem Telefonterror ein Ende setzen zu können.
Ich habe es nun installieren können und ich kann auch im "normalen" Lauf bei eingehenden Telefonaten (habe erstmal nur mein Handy zum testen) sehen, dass er die Whitelist meines Handys erkennt oder bei Rufunterdrücken CLIR erkennt.

Ich wollte dann testen ausprobieren run fbcallrouter run -t

dabei kommt dann dieses in der Konsole (läuft auf einem PHP8-cli docker):

root@PHP8-Cli:/home/fbcallrouter# php fbcallrouter run -t                                                                    
                                                                                                                             
Deprecated: Return type of Symfony\Component\Console\Helper\HelperSet::getIterator() should either be compatible with Iterato
rAggregate::getIterator(): Traversable, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the 
notice in /home/fbcallrouter/vendor/symfony/console/Helper/HelperSet.php on line 104                                         
Starting FRITZ!Box call router...                                                                                            
On guard...                                                                                                                  
Running test case 1 of 5                                                                                                     
                                                                                                                             
Warning: Array to string conversion in /home/fbcallrouter/src/functions.php on line 94                                       
                                                                                                                             
Warning: Undefined variable $Array in /home/fbcallrouter/src/functions.php on line 94                                        
                                                                                                                             
Fatal error: Uncaught TypeError: blacksenator\callrouter\dialercheck::proofRating(): Argument #1 ($rating) must be of type ar
ray, null given, called in /home/fbcallrouter/src/functions.php on line 94 and defined in /home/fbcallrouter/src/callrouter/d
ialercheck.php:166                                                                                                           
Stack trace:                                                                                                                 
#0 /home/fbcallrouter/src/functions.php(94): blacksenator\callrouter\dialercheck->proofRating(NULL)                          
#1 /home/fbcallrouter/src/RunCommand.php(32): blacksenator\callRouter(Array, Array)                                          
#2 /home/fbcallrouter/vendor/symfony/console/Command/Command.php(255): blacksenator\RunCommand->execute(Object(Symfony\Compon
ent\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))                                        
#3 /home/fbcallrouter/vendor/symfony/console/Application.php(992): Symfony\Component\Console\Command\Command->run(Object(Symf
ony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))                              
#4 /home/fbcallrouter/vendor/symfony/console/Application.php(255): Symfony\Component\Console\Application->doRunCommand(Object
(blacksenator\RunCommand), Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\Console
Output))                                                                                                                     
#5 /home/fbcallrouter/vendor/symfony/console/Application.php(148): Symfony\Component\Console\Application->doRun(Object(Symfon
y\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))                                
#6 /home/fbcallrouter/fbcallrouter(16): Symfony\Component\Console\Application->run()                                         
#7 {main}                                                                                                                    
  thrown in /home/fbcallrouter/src/callrouter/dialercheck.php on line 166                                                                                                     

meine config.php ist noch kaum angepasst, habe dies hier:

<?php

$config = [
    'fritzbox' => [
        'url'      => 'fritz.box',          // your Fritz!Box IP
        'user'     => 'FBCallMonitor',           // your Fritz!Box user
        'password' => '****',         // your Fritz!Box user password
    ],
    'phonebook' => [
        'whitelist' => [0], // phonebooks to check against if this number is already known (first = 0!)
        'blacklist' => 1,   // phonebook in which the spam number should be recorded
        'newlist'   => 2,   // optional: phonebook in which the reverse searchable entries should be recorded
        'refresh'   => 1,   // after how many days the whitelist should be read again
    ],
    'contact' => [
        'caller'    => 'autom. gesperrt',   // alias for the new unknown caller
        'timestamp' => true,    // adding timestamp to the caller: "[caller] ([timestamp])"
        'type'      => 'other',     // type of phone line (home, work, mobil, fax etc.); 'other' = 'sonstige'
    ],
    'filter' => [
        'blockForeign' => false, // block unknown foreign numbers
        'score'        => 6,    // 5 = neutral, increase the value to be less sensitive (max. 9)
        'comments'     => 3,    // decrease the value to be less sensitive (min 3)
    ],
    'logging' => [
        'log'     => true,
        'logPath' => '',    // were callrouter_logging.txt schould be saved (default value is = './')
    ],
    'test' => [                 // if program is started with the -t option...
        'numbers' => [          // ...the numbers are injected into the following calls
            '03681443300750',   // tellows score > 5, comments > 3
            '0207565747377',    // not existing NDC/STD (OKNz)
            '0618107162530',    // valid NDC/STD, but invalid subscriber number
            '004433456778',     // foreign number
            '',                 // unknown caler (uses CLIR)
        ],
    ],
];

Hab ich was übersehen?

Workaround to keep Fritzbox Callmonitor alive for a longer time

UPDATE: Dies war eine fruehe Loesung, die m.E. "Bessere" findet sich erst im naechsten Kommentar.

Beim bisherigen Ansatz den $fbSocket vorher einmalig aufzusetzen, und dann in der Loop nur noch mittels fgets($fbSocket); davon zu lesen gibt es - wie schon per email berichtet - das Problem, dass nach einiger Zeit (zB nach 2 Stunden), scheinbar selbst dann wenn Anrufe eingehen, "irgendwie" nicht mehr gesendet wird, was zu parsen waere, statt dessen geraet er immer in den else-Zweig.

Nach Lesen einiger Kommentare im Netz, die ebenso das Problem hatten dass sie nach einiger Zeit nichts mehr vom CallMonitor lesen konnten, und daher einfach die Verbindung neu aufsetzten, habe ich auf Verdacht das Gleiche adaptiert, grob:

    $fbSocket = false; // will be initialised below
    $counter = 0;
    while (true) {

        if ($counter % 80 == 0) {
            $fbSocket = $callrouter->getSocket();
            stream_set_timeout ($fbSocket, 1);        
        }     
        $counter += 1;

       [hier der bisherige Code der Loop]
    }

Und das scheint dem abzuhelfen. Natuerlich kann man sich streiten wie oft man sich neu verbindet, hier ist es irgendwas ueber jede 80 Sekunden, wenn man das sleep oder timeout bedenkt. Ich stelle das einfach mal als proof of concept ein, ohne PR - koennte aber gerne auch einen solchen erstellen ;-) Man muesste halt wissen/eruieren nach welcher ungefaehren Zeit dieses Problem auftritt. BTW, hatte ich auch Deinen bisherigen Ansatz (Socket nur einmal aufsetzen) versucht mit dem extra Flag STREAM_CLIENT_PERSISTENT, aber das half leider nicht.

PS: die andere Issue dass neue Eintraege nicht ins Telefonbuch eingefuegt werden koennen ("manchmal"), habe ich eine extra Issue erstellt.

Quellen:
https://forum.fhem.de/index.php?topic=41195.0
https://forum.fhem.de/index.php?topic=86590.0
https://community.home-assistant.io/t/fritzbox-callmonitor-loosing-connection/57789/3

Warum gesperrt

12.09.2022 14:00:55 => Status: Regular Socket refresh
12.09.2022 14:02:45 => CALL IN from number 01517082XXXX to MSN 68XX
12.09.2022 14:02:45 => The caller is using an illegal subscriber number! Added $
12.09.2022 14:03:32 => DISCONNECT

Warum wird die Nummer gesperrt
Danke

extension=sockets have to be enabled in php.ini

The config style has changed, tz ,) But that's not what this issue is about:

I got an exception that socket_import_stream would be unknown.. I googled the solution, it's easy to solve: you have to uncomment the line sockets in the php.ini file:

extension=sockets

Maybe just upgrade the README to mention this?

BTW, will have a long running test on W10 today and check if the problem with the silent socket is really fixed. ETA of result maybe 8:00 pm, after swimming.

PS: sockets war also bei mir bislang auskommentiert - frag mich nicht warum dann andere socket-Funktionen trotzdem taten. Ist sicher wieder sowas Unergruendliches meiner Lieblingshasssprache ,)

Integration mit PhoneBlock

Ich habe vor einiger Zeit das Projekt PhoneBlock (https://github.com/haumacher/phoneblock) gestartet, dass eine Sperrliste als Internet-Adressbuch für die Fritz!Box zur Verfügung stellt. Man kann das PhoneBlock-Adressbuch in der Fritz!Box einrichten und dort alle Anrufe von der Blocklist automatisch abweisen lassen (live auszuprobieren hier: https://phoneblock.haumacher.de/). Der Vorteil ist, dass man keine Zusatzhardware benötigt. Der Nachteil ist aber, dass PhoneBlock keine Rückmeldung erhält, wenn Spam-Anrufe weggefiltert werden. Daher ist es schwer zu sagen, ob eine Spam-Nummer noch aktiv ist. Da ein Adresssbuch in der Fritz!Box nur begrenzt viele Nummer aufnehmen kann, muss man aber immer wieder Nummer von der Blocklist streichen.

Wenn ich das richtig verstanden habe, dann beobachtet fbcallrouter aktiv die Anrufe in der Fritz!Box und könnte der Datenbank mit Spam-Nummer eine Rückmeldung geben, dass ein Anruf weggefiltert worden ist. Ich würde gerne eine (einfache) Schnittstelle bereitstellen, mit der fbcallrouter die Blocklist von PhoneBlock abrufen/synchronisieren kann - im Gegenzug könnte fbcallrouter PhoneBlock mit Informationen versorgen, wenn ein Anruf tatsächlich blockiert wurde.

Kannst Du sagen, wieviele Installationen es von fbcallrouter gibt?

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.