如何在运行时加载Strongswan插件

问题描述 投票:0回答:1

我们已经为libcharon编写了一个插件,该插件可以调用我们的代码。因为我们正在使用此插件编译Strongswan,所以这在我们的应用程序和Strongswan之间造成了不必要的耦合。

我们将此插件称为MyPlugin。它的配置如下:

$ cat /etc/strongswan/strongswan.d/charon/myplugin.conf
myplugin {

    # Whether to load the plugin. Can also be an integer to increase the
    # priority of this plugin.
    load = yes

    proxy
    {
        # Should send to proxy
          send_to_proxy = yes
    }
    log
    {
                # Should save to file
                  log_path = /var/log/myplugin.log
                  log_ips = yes
    }
}

我们想通过将此插件编译为应用程序的一部分,实现strongswan接口来扭转这种依赖性。

问题是,strongswan支持吗?可以将插件部署在已运行Strongswan的计算机上,并让Strongswan加载并使用它吗?怎么样?

我们正在CentOS 6上运行Strongswan 5.1.5。

linux plugins centos6 strongswan
1个回答
0
投票

是的,您可以这样做。但是,有一些警告:

  • strongSwan不提供任何稳定的API。因此,仅当您针对将最终加载该插件的strongSwan版本的标头编译插件时,此方法才安全地工作。
  • 您将需要从您正在编译的构建(或同一平台的等效配置的构建)中获取config.h。编译插件时,您可以通过-include传递路径。
  • 通过配置代码段加载插件需要一个适当的strongswan.conf文件(即,启用modular plugin loading并将配置代码段包含在strongswan.d中,在其中您为插件放置代码段-the default应该可以正常工作)。
  • [第三方插件可能存在许可问题,无论是否在树外(strongSwan都是根据GPLv2许可的,但是都有商业许可)。

您可以找到树外插件here的示例。

© www.soinside.com 2019 - 2024. All rights reserved.