Freeswitch ACL configuration for remote event socket - node.js

I have a FS server running on one server and on a remote server I have a Node JS instance controlling it using node_esl (a Node JS Event Socket library for FS).
Every time I'm sending a request to the server I have the following error:
[WARNING] mod_event_socket.c:2603 IP ::ffff:192.168.59.3 Rejected by acl "loopback.auto"
FS server has 2 interfaces: one is using a public IP and the second one is on a private network (192.168.59.0/24).
I checked the acl.conf.xml file and event_socket.con.xml and I do not see anything special so far.
One last thing: this is a dev environment and FS is running in a VM (VirtualBox). The interface used for the VM is 192.168.59.103 and the GW is 192.168.59.3
So this might be a NAT issue if not an ACL issue (or both).
Do you have any idea of what the ACL configuration should be?

You must go to FreeSWITCH/conf/autoload_configs/event_socket.conf.xml and uncoment and edit acl line:
<param name="apply-inbound-acl" value="loopback.auto"/>
you must write something like my_acl instead of loopback.auto
After that you must go to FreeSWITCH/conf/autoload_configs/acl.conf.xml and there write something like this:
<list name="my_acl" default="deny">
<node type="allow" cidr="xxx.xxx.xxx.xxx/32"/>
<node type="allow" cidr="xxx.xxx.xxx.0/24"/>
</list>
After this go to fs_cli and tape command:
reloadacl
Enjoy!
EDIT:
Make sure following:
<list name="my_acl" default="deny">
<node type="allow" cidr="xxx.xxx.xxx.xxx/32"/>
<node type="allow" cidr="xxx.xxx.xxx.0/24"/>
</list>
becomes:
<list name="my_acl" default="deny">
<node type="allow" cidr="xxx.xxx.xxx.xxx/32"/>
<node type="allow" cidr="xxx.xxx.xxx.0/24"/>
<node type="allow" cidr="192.168.42.42/32"/>
<node type="allow" domain="$${domain}"/>
<!-- this allow fs_cli to connect else fs_cli wont work --!>
<node type="allow" cidr="127.0.0.1/32" />
</list>

I found out why:
ACL was not really that well configured. The one used was not opening the right connection for event_socket. So either Event_Socket was opened for local use only or for external use only.
Had to recreate a new ACL with local access opened (necessary if you want to use fs_cli) and adding the IPs of the controlling servers.
Thx for your suggestion regarding IPv6, I tested it earlier and found out it has no effect on my "issue"

There's some info on how to get it to work here:
https://wiki.freeswitch.org/wiki/Mod_event_socket#Configuration
After a bit of trial and error, all I had to do to get rid of the error was the following:
Open FreeSWITCH/conf/autoload_configs/event_socket.conf.xml
Uncomment the following line:
<param name="apply-inbound-acl" value="loopback.auto"/>
Here's my working event_socket.conf.xml file:
<configuration name="event_socket.conf" description="Socket Client">
<settings>
<param name="nat-map" value="false"/>
<param name="listen-ip" value="::"/>
<param name="listen-port" value="8021"/>
<param name="password" value="ClueCon"/>
<param name="apply-inbound-acl" value="loopback.auto"/>
<!--<param name="stop-on-bind-error" value="true"/>-->
</settings>
</configuration>

I manually created loopback.auto list under acl.conf.xml
<list name="loopback.auto" default="allow">
<node type="allow" cidr="172.31.0.0/16"/>
<node type="allow" cidr="52.67.85.153/32"/>
</list>
Where 172.31.0.0/16 is Freeswitch local IP address.
In event_socket.conf.xml file I leave loopback.auto:
<param name="apply-inbound-acl" value="loopback.auto"/>
Then run reloadacl and reloadxml. In my case I needed to restart Freeswitch to make it work.

It could happen because of IPv6 issue:
https://freeswitch.org/jira/browse/FS-7638
As a workaround, you can try to change event_socket bind address from :: to 192.168.59.x in autoload_configs/event_socket.conf.xml

Related

Enabing IIS using CAQuietExec64 in Wix installer does not work

I need to make a windows installer which enables (installs) IIS on windows.
When I run the .msi file, it runs without any give any however, IIS does not get enabled(installed) when I go to Program and Features/Turn Windows Feature on off, it does not get installed
Here is my wxs file:
<?xml version="1.0" encoding="UTF-8"?>
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">
<Product Id="*" Name="IISInstaller" Language="1033" Version="1.0.0.0" Manufacturer="Company" UpgradeCode="21ece05f-bf5c-4f97-850e-cb7cef2bf65e">
<Package InstallerVersion="200" Compressed="yes" InstallScope="perMachine" />
<MajorUpgrade DowngradeErrorMessage="A newer version of [ProductName] is already installed." />
<MediaTemplate />
<Property Id="QtExec64CmdLine" Value='"[WindowsFolder]Sysnative\dism.exe" /Online /Enable-Feature /FeatureName:IIS-ApplicationDevelopment /FeatureName:IIS-WebServer
/FeatureName:IIS-WebServerRole /FeatureName:IIS-RequestFiltering /FeatureName:IIS-Security
/FeatureName:IIS-NetFxExtensibility /FeatureName:IIS-ASPNET /FeatureName:IIS-ISAPIExtensions
/FeatureName:IIS-ISAPIFilter /FeatureName:IIS-DefaultDocument /FeatureName:IIS-HttpErrors /FeatureName:IIS-StaticContent
/FeatureName:IIS-HttpLogging /FeatureName:IIS-RequestMonitor /FeatureName:IIS-HttpCompressionStatic
/FeatureName:IIS-HttpCompressionDynamic /FeatureName:IIS-RequestFiltering /FeatureName:IIS-WindowsAuthentication'/>
<CustomAction Id="SilentLaunch" BinaryKey="WixCA" DllEntry="CAQuietExec64" Execute="immediate" Return="check" />
</Product>
</Wix>
even when I change the value in the property to run a simple command to make directory
mkdir test
it does not work either.
Could you please help me what is the problem?
Thanks
Two potential problems:
You have declared the custom action but you haven't put it in a sequence by declaring where it's going to run and what conditions apply. So it didn't run.
Step 2 is missing: http://wixtoolset.org/documentation/manual/v3/wixdev/extensions/authoring_custom_actions.html
After you've done that, the custom action is marked immediate which is usually an error because changes to the system should be done in deferred mode, and immediate custom actions don't run elevated.

log4net not creating log file upon installation

I have searched far and wide for my solution (including relevant stackoverflow questions) but have yet to find an answer that fixes my issue. I have been using log4net successfully in a work project and when I run the program in visual studio I get my log file. If I install the program using the msi installer (wix) then I do NOT get a log file. I'll first list things I've tried, followed by an edited version of my code.
Also, anywhere I say "appname" I did not actually put appname, just keeping project name out of post.
I'm placing the log file in ${USERPROFILE}\AppData\Local[appname] directory, permissions are not an issue.
Since the config file that is present in the installed version is appname.exe.config instead of app.config, I changed the Assemblyinfo.cs assembly statement to appname.exe.config. This however did not solve my issue, it still only works while running through visual studio, an installed version does not.
I have modified product.wxs to deliver log4net.dll and log4net.xml to the install directory. (forgot to do this, app would not start so came back and added it in) still no change.
We have 5 projects within a single solution using log4net. all of the assemblyinfo.cs files have the following:
[assembly: log4net.Config.XmlConfigurator(ConfigFile = "appname.exe.config", Watch = true)]
I was using [assembly: log4net.Config.XmlConfigurator(ConfigFile = "app.config", Watch = true)] but changed this to the modified config file name that is placed in the install dir and the bin.
Inside of app.config(excuse any possible typos, my dev machine is airgapped and I cannot copy paste the code):
<configuration>
<configSections>
<section name="log4net" type="log4net.Config.Log4NetConfigurationSectionHandler, log4net"/>
</configSections>
<log4net>
<root>
<level value="ALL"/>
<appender-ref ref="MyAppender"/>
</root>
<appender name="MyAppender" type="log4net.Appender.FileAppender">
<file value="${USERPROFILE}\AppData\Local\appname\appname.log"/>
<appendToFile value="true"/>
<lockingModel type="log4net.Appender.FileAppender+MinimalLock"/>
<layout type="log4net.Layout.PatternLayout">
<conversionPattern value="%date %level - %message%newline"/>
</layout>
</appender>
</log4net>
</configuration>
and in my c# code where I use the logger:
private static readonly log4net.ILog Log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
If your configuration is in your app.config, you can just use:
[assembly: log4net.Config.XmlConfigurator(Watch = true)]
When you specify a file, log4net expect the log4net element as xml root element. Which is not true for your app.config.
#erike i'm not sure it was mine. So I do not have an link for you.

xdt:Transform fails to change mailsettings

Before I start I would like to say that I have read and tried all methods/solutions I can find on this and other forums to no avail.
I have a simple mail setting entry in my webconfig that I want transformed when publishing to test environment etc.
This is the main config that uses my local settings
<system.net>
<mailSettings>
<smtp from="p.carey#sentinelwater.co.uk">
<network host="SENTINEL-SBS" port="25" />
</smtp>
</mailSettings>
</system.net>
and this is one of the attempted transforms
<system.net>
<mailSettings>
<smtp from="noreply#test.managemywater.co.uk" xdt:Transform="Replace">
<network xdt:Transform="Replace" host="localhost" port="25" />
</smtp>
</mailSettings>
</system.net>
It simply fails on replacing 'host' with localhost and maintains SENTINEL-SBS. I have no idea if it attempts to replace 'from'.
I have run out of ideas and will have to resort to translating Japanese forums now!!!
No doubt there is a simple answer but I'll be damned if I can find it.
I have an addition transform for the connection string using 'add name' and that works fine.

IISExpress Log File Location

IISExpress writes log and configuration data to pre-determined location out of the box.
The directory is an "IISExpress" directory stored in a user's Documents directory.
In the directory is stored the following folders files underneath.
Config
Logs
TraceLogFiles
The location of my home directory is on a network share, determined by group policy
Currently we are encountering scenarios where visual studio locks up when stopping debugging Silverlight applications using IIS Express.
I was looking to change the location for the log & configuration data for IISExpress to see if this fixes the problem of visual studio locking up. Is it possible to change the default location of log & config files ?
1 . By default applicationhost.config file defines following two log file locations. Here IIS_USER_HOME would be expanded as %userprofile%\documents\IISExpress\.
<siteDefaults>
<logFile logFormat="W3C" directory="%IIS_USER_HOME%\Logs" />
<traceFailedRequestsLogging directory="%IIS_USER_HOME%\TraceLogFiles" enabled="true" />
</siteDefaults>
You can update above directory paths to change the log file locations.
2 . If you are running IIS Express from command line, you can use '/config' switch to provide configuration file of your choice. Following link may help you http://learn.iis.net/page.aspx/870/running-iis-express-from-the-command-line/
http://www.iis.net/configreference/system.applicationhost/sites/sitedefaults
<configuration>
<system.applicationHost>
<sites>
<siteDefaults>
<logFile
logFormat="W3C"
directory="%SystemDrive%\inetpub\logs\LogFiles"
enabled="true"
/>
<traceFailedRequestsLogging
enabled="true"
directory="%SystemDrive%\inetpub\logs\FailedReqLogFiles"
maxLogFiles="20"
/>
<limits connectionTimeout="00:01:00" />
<ftpServer serverAutoStart="true" />
<bindings>
<binding
protocol="http"
bindingInformation="127.0.0.1:8080:"
/>
</bindings>
</siteDefaults>
</sites>
</system.applicationHost>
</configuration>
I find web.config documentation is a messy. It is therefore better to provide a complete parent history than a floating snippet with the expectation that the reader naturally knows where it goes.
By default it will be in:
C:\Users\ user_name \Documents\IISExpress\Logs\

Why is the date appended twice on filenames when using Log4Net?

I was trying to add the date to my log file name and I was able to make it work by following the few suggestions I've found in stackoverflow. Everything works fine but for some reason, the first file always has the date appended twice.
For example, instead of log.2009-02-23.log, I get log.2009-02-23.log.2009-02-23.log.
I found it so weird and fyi, this is a very simple code. It's not like I have it running in a multi-threaded environment.
My log4net config:
<log4net>
<appender name="MyLog" type="log4net.Appender.RollingFileAppender">
<file value="../../Logs/Mylog"/>
<staticLogFileName value="false" />
<appendToFile value="true"/>
<rollingStyle value="Date"/>
<datePattern value=".yyyy-MM-dd.lo\g" />
<lockingModel type="log4net.Appender.FileAppender+MinimalLock" />
<layout type="log4net.Layout.PatternLayout">
<conversionPattern value="%d{DATE} [%t] %-5p %c - %m%n"/>
</layout>
</appender>
<root>
<level value="INFO"/>
<appender-ref ref="MyLog"/>
</root>
</log4net>
Any ideas why?
Edit: I want to add the information about the environment I'm testing this in.
- asp.net
- .net framework 2.0
- windows server 2003 64-bit service pack 2
- log4net 1.2.10
This happens if there is a problem accessing the log file when you initialize the log system.
It can happen if you initialize the log system twice, if you run your program while another copy is running and writing to the log file, or if you are editing the log file in a text editor. Basically anything that causes a write lock on the log file when log4net init runs.
Check your code for duplicate calls to log4net init - perhaps you are initializing in a constructor instead of in a singleton's static constructor or global init, for example.
This can also happen if you are running in a 'web garden' configuration and don't include the PID in the filename, because each different web server process tries to write to the same file. If using web gardens and writing to files, add the pid to the filename pattern so each server process gets its own file.
It's a permission problem. At least that's what's happening to me.
I'm new in using Log4Net so I didn't know that it has internal logging but I found it so I tried turning internal logging on.
I wasn't very sure what it's saying but here's what it looks like to me it's doing:
1. Append the date to the file name.
2. Try to access the file to write to it (failed).
3. Append the date to the file name again.
4. Successfully access the file (which has the weird file name now)
Before I know this, I was google-ing for the solution to this problem with keywords like what I have as a title on this stackoverflow question. There wasn't that much information out there. I found maybe one guy who said it happens to some people but never really explained why nor the solution. With this new information (+the internal error message from Log4Net), I was looking at different threads from the search engines. With that I found hints that it might be a permission problem.
It seems that the writing application doesn't have sufficient permission to the logs folder. The default identity of the application is usually NETWORK_SERVICE. After I give more permission (I gave it full control but i don't know what is the minimum to make it work) to the folder, it works just fine.
If anyone can explain this better than me, please feel free to edit.
I run into the same problem. For me, it was a combination of using RollingFileAppender for my test logs, and running my NUnit tests with ReSharper.
It turns out that ReSharper uses two processes to run the tests:
which creates a race condition on the log file.
Now, if we change the log file name to include the process id:
<appender name="MyLog" type="log4net.Appender.RollingFileAppender">
<file type="log4net.Util.PatternString" value="MyLog.pid.%processid" />
<appendToFile value="true" />
<rollingStyle value="Composite" />
<maxSizeRollBackups value="10" />
<maximumFileSize value="10MB" />
<staticLogFileName value="false"/>
<datePattern value="_yyyy-MM-dd'.log'"/>
<layout type="log4net.Layout.PatternLayout">
<conversionPattern value="%d{HH:mm:ss.fff} [%15.15t] %-5p '%40.40c' - %m%n" />
</layout>
</appender>
the problem is solved. Each file gets its own, unique name:
MyLog.pid.5440_2010-10-13.log
MyLog.pid.1496_2010-10-13.log
Note the use of PatternString for 'type'.
Hope that helps.
As olle pointed out. your problem is related to the '\g', which your log4net is interpreting as another dateformat.
Try deleting the ".yyyy-MM-dd.lo\g" and replacing it with "yyyy-MM-dd"
The ".log" doesn't belong in the dateformat
I use the following:
<param name="DatePattern" value="yyyy.MM.dd.\l\o\g"/>
With this I get filenames like: 2009.02.23.log
try <datePattern value=".yyyy-MM-dd.lo\g" /> I don't understand what the \g is for.

Resources