### Description
Event routes that are executed without a real SIP message available use the default "fake SIP message". The fake message has a source IPv4 address of 1.0.0.127 which belongs to CloudFlare (1.0.0.0/24).. and this led us to believe that traffic is coming from CF but could not find the messages on tcpdumps or HEP exports. Had a bit of a wild goose chase there trying to find the source. I believe the original intention has been to use 127.0.0.1 loopback address but the bytes are reversed at:
https://github.com/kamailio/kamailio/blob/master/src/core/fmsg.c#L78
It would be best to change this address to well ANYTHING that doesn't imply CloudFlare is pinging you 😂
--
Reply to this email directly or view it on GitHub:
https://github.com/kamailio/kamailio/issues/3817
You are receiving this because you are subscribed to this thread.
Message ID: <kamailio/kamailio/issues/3817(a)github.com>
kemi_mock.py can now optionally consume documentation information generated by the vscode-kamailio-hover project
<!-- Kamailio Pull Request Template -->
<!--
IMPORTANT:
- for detailed contributing guidelines, read:
https://github.com/kamailio/kamailio/blob/master/.github/CONTRIBUTING.md
- pull requests must be done to master branch, unless they are backports
of fixes from master branch to a stable branch
- backports to stable branches must be done with 'git cherry-pick -x ...'
- code is contributed under BSD for core and main components (tm, sl, auth, tls)
- code is contributed GPLv2 or a compatible license for the other components
- GPL code is contributed with OpenSSL licensing exception
-->
#### Pre-Submission Checklist
<!-- Go over all points below, and after creating the PR, tick all the checkboxes that apply -->
<!-- All points should be verified, otherwise, read the CONTRIBUTING guidelines from above-->
<!-- If you're unsure about any of these, don't hesitate to ask on sr-dev mailing list -->
- [x] Commit message has the format required by CONTRIBUTING guide
- [x] Commits are split per component (core, individual modules, libs, utils, ...)
- [x] Each component has a single commit (if not, squash them into one commit)
- [ ] No commits to README files for modules (changes must be done to docbook files
in `doc/` subfolder, the README file is autogenerated)
#### Type Of Change
- [ ] Small bug fix (non-breaking change which fixes an issue)
- [ ] New feature (non-breaking change which adds new functionality)
- [ ] Breaking change (fix or feature that would change existing functionality)
#### Checklist:
<!-- Go over all points below, and after creating the PR, tick the checkboxes that apply -->
- [ ] PR should be backported to stable branches
- [ ] Tested changes locally
- [ ] Related to issue #XXXX (replace XXXX with an open issue number)
#### Description
<!-- Describe your changes in detail -->
You can view, comment on, or merge this pull request online at:
https://github.com/kamailio/kamailio/pull/3818
-- Commit Summary --
* tools/kemi: add dockstrings to the mocking
-- File Changes --
M misc/tools/kemi/python_mock/README.md (15)
M misc/tools/kemi/python_mock/kemi_mock.py (31)
-- Patch Links --
https://github.com/kamailio/kamailio/pull/3818.patchhttps://github.com/kamailio/kamailio/pull/3818.diff
--
Reply to this email directly or view it on GitHub:
https://github.com/kamailio/kamailio/pull/3818
You are receiving this because you are subscribed to this thread.
Message ID: <kamailio/kamailio/pull/3818(a)github.com>
Module: kamailio
Branch: master
Commit: 6b29df73115682424daf7b276d0138f004e274f7
URL: https://github.com/kamailio/kamailio/commit/6b29df73115682424daf7b276d0138f…
Author: tsearle <torrey.searle(a)wavecrest.com>
Committer: GitHub <noreply(a)github.com>
Date: 2024-04-22T12:53:48+02:00
tools/kemi: add dockstrings to the mocking (#3818)
kemi_mock.py can now optionally consume documentation information
generated by the vscode-kamailio-hover project
---
Modified: misc/tools/kemi/python_mock/README.md
Modified: misc/tools/kemi/python_mock/kemi_mock.py
---
Diff: https://github.com/kamailio/kamailio/commit/6b29df73115682424daf7b276d0138f…
Patch: https://github.com/kamailio/kamailio/commit/6b29df73115682424daf7b276d0138f…
---
diff --git a/misc/tools/kemi/python_mock/README.md b/misc/tools/kemi/python_mock/README.md
index 5e72e738c58..385cbd5656a 100644
--- a/misc/tools/kemi/python_mock/README.md
+++ b/misc/tools/kemi/python_mock/README.md
@@ -2,7 +2,7 @@
Generate a mocking framework base on the output of app_python.api_list
-Usage:
+### Usage:
```
/usr/sbin/kamctl rpc app_python.api_list > api.json
./kemi_mock.py api.json > KSR.py
@@ -15,6 +15,19 @@ the Union type add the --no-union flag
./kemi_mock.py api.json --no-union > KSR.py
```
+### Usage with Documentation:
+run the generate.py from the following project
+
+https://github.com/braams/vscode-kamailio-hover
+
+this creates a modules.json file in a tmp directory. This file can be used to generate the KSR.py file with documentation
+
+pass the modules.json as a 2nd parameter to kemi_mock.py
+```
+./kemi_mock.py api.json modules.json > KSR.py
+```
+
+## Mocking
Return values can be injected through the dictionary \_mock\_data
```python
diff --git a/misc/tools/kemi/python_mock/kemi_mock.py b/misc/tools/kemi/python_mock/kemi_mock.py
index 48a73efa232..145fcb34b3a 100755
--- a/misc/tools/kemi/python_mock/kemi_mock.py
+++ b/misc/tools/kemi/python_mock/kemi_mock.py
@@ -113,21 +113,41 @@ def printFunction(module_name, func, indent):
else:
print(prefix + "def " + func['name'] +"("+params+"):")
+ generate_function_doc(module_name, func, prefix)
+
print(prefix + "\tprint(\"Calling " + log_format_params + "\" % "+log_params+")")
printMocReturn(module_name, func, indent+1)
print("")
+def generate_function_doc(module_name, func, prefix):
+ if documentation is not None and module_name in documentation:
+ function_parts = func['name'].split("_")
+ for i in range(len(function_parts), 0, -1):
+ function_prefix = "_".join(function_parts[:i])
+ if function_prefix in documentation[module_name]["functions"]:
+ print(prefix + "\t\"\"\"")
+ documentation_lines = documentation[module_name]["functions"][function_prefix].split("\n")
+ for line in documentation_lines:
+ print(prefix + "\t" + line)
+ print(prefix + "\t\"\"\"")
+ break
+
+
classes = defaultdict(list)
if len(sys.argv) < 2:
print("Please specify the json file to parse")
sys.exit(-1)
+documentation = None
if len(sys.argv) > 2:
for i in range(2,len(sys.argv)):
if sys.argv[i] == "--no-union":
noUnion = True
+ else:
+ with open(sys.argv[i]) as f:
+ documentation = json.load(f)
if not noUnion:
print("from typing import Union")
@@ -193,12 +213,23 @@ def printFunction(module_name, func, indent):
print("")
printFunction('', func, 0)
+
+def document_module(module_name):
+ if documentation is not None and module_name in documentation:
+ print("\"\"\"")
+ documentation_lines = documentation[module_name]["overview"].split("\n")
+ for line in documentation_lines:
+ print("" + line)
+ print("\"\"\"")
+
+
for module_name in classes.keys():
if module_name != "":
if module_name in reserved_keywords:
print("setattr(sys.modules[__name__], '" + module_name + "', " + module_name.capitalize() + "())")
else:
print(module_name + " = "+module_name.capitalize()+"()")
+ document_module(module_name)
print("")