没有项目描述

mudd的Python项目详细描述


泥泞

PyPI version

muddy是一个用于生成mud文件(RFC8520)的python包和cli工具。

用法

根据抽象级别的不同,有多种方法可以生成mud对象:

frommuddy.makerimportmake_mudfrommuddy.modelsimportDirection,IPVersion,Protocol,MatchTypemud=make_mud(1,'https://lighting.example.com/lightbulb2000',48,True,'The BMS Example Light Bulb','https://lighting.example.com/lightbulb2000/documentation',[Direction.TO_DEVICE,Direction.FROM_DEVICE],IPVersion.IPV4,'test.example.com',Protocol.ANY,MatchType.IS_MYMFG,[88,443],[88,443])

frommuddy.makerimportmake_mud,make_support_infofrommuddy.modelsimportDirection,IPVersion,Protocol,MatchTypesupport_info=make_support_info(1,'https://lighting.example.com/lightbulb2000',48,True,'The BMS Example Light Bulb','https://lighting.example.com/lightbulb2000/documentation')mud=make_mud(support_info,[Direction.TO_DEVICE,Direction.FROM_DEVICE],IPVersion.IPV4,'test.example.com',Protocol.ANY,[88,443],[88,443],MatchType.IS_MYMFG)

frommuddy.makerimportmake_mud,make_acl_names,make_policy,make_aclsfrommuddy.modelsimportDirection,IPVersion,Protocol,MatchTypeimportrandommud_name=f'mud-{random.randint(10000, 99999)}'acl=[]policies={}fordirection_initiatedin[Direction.TO_DEVICE,Direction.FROM_DEVICE]:acl_names=make_acl_names(mud_name,IPVersion.IPV4,direction_initiated)policies.update(make_policy(direction_initiated,acl_names))acl.append(make_acls([IPVersion.IPV4],'test.example.com',Protocol.ANY,[88,443],[88,443],MatchType.IS_MYMFG,direction_initiated,acl_names))mud=make_mud(policies,acl,1,'https://lighting.example.com/lightbulb2000',48,True,'The BMS Example Light Bulb','https://lighting.example.com/lightbulb2000/documentation')

frommuddy.makerimportmake_mud,make_acl_names,make_policy,make_acls,make_support_infofrommuddy.modelsimportDirection,IPVersion,Protocol,MatchTypeimportrandomsupport_info=make_support_info(1,'https://lighting.example.com/lightbulb2000',48,True,'The BMS Example Light Bulb','https://lighting.example.com/lightbulb2000/documentation')mud_name=f'mud-{random.randint(10000, 99999)}'acl=[]policies={}fordirection_initiatedin[Direction.TO_DEVICE,Direction.FROM_DEVICE]:acl_names=make_acl_names(mud_name,IPVersion.IPV4,direction_initiated)policies.update(make_policy(direction_initiated,acl_names))acl.append(make_acls([IPVersion.IPV4],'test.example.com',Protocol.ANY,[88,443],[88,443],MatchType.IS_MYMFG,direction_initiated,acl_names))mud=make_mud(support_info,policies,acl)

要获取mud对象的json,您只需json.dumps(mud)

示例输出

{"ietf-mud:mud":{"mud-version":1,"mud-url":"https://lighting.example.com/lightbulb2000","last-update":"2019-07-23T19:54:24","cache-validity":48,"is-supported":true,"systeminfo":"The BMS Example Light Bulb","documentation":"https://lighting.example.com/lightbulb2000/documentation","to-device-policy":{"access-lists":{"access-list":[{"name":"mud-52892-v4to"}]}},"from-device-policy":{"access-lists":{"access-list":[{"name":"mud-52892-v4fr"}]}}},"ietf-access-control-list:acls":{"acl":[{"name":"mud-52892-v4to","type":"ipv4","aces":{"ace":[{"name":"myman0-todev","matches":{"ietf-mud:mud":{"same-manufacturer":[]}},"actions":{"forwarding":"accept"}},{"name":"myman1-todev","matches":{"ietf-mud:mud":{"same-manufacturer":[]}},"actions":{"forwarding":"accept"}},{"name":"myman1-todev","matches":{"ietf-mud:mud":{"same-manufacturer":[]}},"actions":{"forwarding":"accept"}},{"name":"myman2-todev","matches":{"ietf-mud:mud":{"same-manufacturer":[]}},"actions":{"forwarding":"accept"}}]}},{"name":"mud-52892-v4fr","type":"ipv4","aces":{"ace":[{"name":"myman0-frdev","matches":{"ietf-mud:mud":{"same-manufacturer":[]}},"actions":{"forwarding":"accept"}},{"name":"myman1-frdev","matches":{"ietf-mud:mud":{"same-manufacturer":[]}},"actions":{"forwarding":"accept"}},{"name":"myman1-frdev","matches":{"ietf-mud:mud":{"same-manufacturer":[]}},"actions":{"forwarding":"accept"}},{"name":"myman2-frdev","matches":{"ietf-mud:mud":{"same-manufacturer":[]}},"actions":{"forwarding":"accept"}}]}}]}}

欢迎加入QQ群-->: 979659372 Python中文网_新手群

推荐PyPI第三方库


热门话题
java Spring启动启用HTTPS   actionscript 3 java中的这个[“var”+“name”]   java只匹配给定集合中一个字符的一个匹配项   java Hibernate:防止角色表中出现多个相同的条目   javajersey+Spring注入servlet请求   java HtmlEditor javafx失去焦点   java Apache Wicket AjaxRequestTarget ListView组件未刷新或更新   mysql java。无法将lang.String转换为java。sql。时间戳   java将巨大的整数文件(在一行中)拆分为具有内存限制的已排序块   安卓如何完全关闭proguard?   安装Eclipse和Android SDK后的java“无AVD可用”消息   java动态显示图像视图   java在Spring中还有哪些WebsocketClient实现?   java Glassfish需要很长时间才能重新启动   使用Java简单串行连接器将pc与arduino连接   java如何在camel文件组件配置中结合readLockCheckInterval和maxMessagesPerPoll?   单击Android时的java预览图像   java如何将字节数组转换为ByteArrayOutputStream