AirenSoft / OvenMediaEngine

OvenMediaEngine (OME) is a Sub-Second Latency Live Streaming Server with Large-Scale and High-Definition. #WebRTC #LLHLS
https://airensoft.com/ome.html
GNU Affero General Public License v3.0
2.55k stars 1.06k forks source link

POST /v1/vhosts/{vhost}/apps/{app}:pushes does not filter when passing an ID #1474

Closed the-real-rusty-shackleford closed 7 months ago

the-real-rusty-shackleford commented 10 months ago

Describe the bug The API documentation for the Get Push Publishing State endpoint states that if id is passed in the body, only the push with that ID will be returned. See below.

{
    "id": "{unique_push_id}"
}

# id (optional)
    unique ID to identify the push publishing task. If no id is given in the request, the full list is returned.

When I pass an id, all pushes are always returned, even if I put in a junk ID that doesn't match any ID.

To Reproduce Steps to reproduce the behavior:

  1. Run two OME instances.
  2. Push a stream from one instance to the other via the API endpoint POST /v1/vhosts/{vhost}/apps/{app}:startPush. Use stream1 as the ID.
  3. POST to /v1/vhosts/{vhost}/apps/{app}:pushes with a body of
    {
      "id": "not-a-real-id"
    }
  4. See that the stream is still returned.

Expected behavior The result should be filtered by ID.

Server (please complete the following information):

the-real-rusty-shackleford commented 10 months ago

The below script creates two instances of OME and starts a push from one instance to the other. Then it queries the pushes API with an invalid ID. The result is that the push is returned anyway.

It certainly seems like PushApplication::GetPushes in application.cpp is trying to filter. I'm not sure why it's failing.

Reproduction Steps

  1. Place both files below (Server.xml and run.sh) into the same directory.
  2. Run run.sh.
  3. See that a push is returned, even though it should have been filtered out.

Files

Server.xml

<?xml version="1.0" encoding="UTF-8" ?>

<Server version="8">
    <Name>OvenMediaEngine</Name>
    <!-- Host type (origin/edge) -->
    <Type>origin</Type>
    <!-- Specify IP address to bind (* means all IPs) -->
    <IP>*</IP>
    <PrivacyProtection>false</PrivacyProtection>
    <!-- 
    To get the public IP address(mapped address of stun) of the local server. 
    This is useful when OME cannot obtain a public IP from an interface, such as AWS or docker environment. 
    If this is successful, you can use ${PublicIP} in your settings.
    -->
    <StunServer>stun.ovenmediaengine.com:13478</StunServer>

    <Modules>
        <LLHLS>
            <Enable>true</Enable>
        </LLHLS>
    </Modules>

    <!-- Settings for the ports to bind -->
    <Bind>
        <!-- Enable this configuration if you want to use API Server -->
        <Managers>
            <API>
                <Port>8081</Port>
                <WorkerCount>1</WorkerCount>
            </API>
        </Managers>
        <Providers>
            <!-- Push providers -->
            <RTMP>
                <Port>1935</Port>
                <WorkerCount>1</WorkerCount>
            </RTMP>
        </Providers>

        <Publishers>
            <LLHLS>
                <Port>3333</Port>
                <WorkerCount>1</WorkerCount>
            </LLHLS>
        </Publishers>
    </Bind>
    <Managers>
        <Host>
            <Names>
                <Name>*</Name>
            </Names>
        </Host>
        <API>
            <AccessToken>test:test</AccessToken>
            <CrossDomains>
                <Url>localhost</Url>
            </CrossDomains>
        </API>
    </Managers>
    <VirtualHosts>
        <VirtualHost>
            <Name>default</Name>

            <Host>
                <Names>
                    <Name>*</Name>
                </Names>
            </Host>

            <!-- Settings for applications -->
            <Applications>
                <Application>
                    <Name>app</Name>
                    <!-- Application type (live/vod) -->
                    <Type>live</Type>
                    <OutputProfiles>
                        <OutputProfile>
                            <Name>bypass_stream</Name>
                            <OutputStreamName>${OriginStreamName}</OutputStreamName>

                            <Encodes>
                                <Video>
                                    <Name>bypass_video</Name>
                                    <Bypass>true</Bypass>
                                </Video>
                                <Audio>
                                    <Name>bypass_audio</Name>
                                    <Bypass>true</Bypass>
                                </Audio>
                            </Encodes>
                        </OutputProfile>
                    </OutputProfiles>
                    <Providers>
                        <RTMP />
                    </Providers>
                    <Publishers>
                        <AppWorkerCount>1</AppWorkerCount>
                        <StreamWorkerCount>1</StreamWorkerCount>
                        <RTMPPush></RTMPPush>
                    </Publishers>
                </Application>
            </Applications>
        </VirtualHost>
    </VirtualHosts>
</Server>

run.sh

OME_TAG=${1:-0.16.3}

docker image pull airensoft/ovenmediaengine:$OME_TAG

docker container rm ome-test-1 --force
docker container rm ome-test-2 --force

echo "Starting OME Instance 1..."

docker run --rm -d \
  --name ome-test-1 \
  -p 1935:1935 \
  -p 8081:8081 \
  -v ./Server.xml:/opt/ovenmediaengine/bin/origin_conf/Server.xml \
  airensoft/ovenmediaengine:$OME_TAG

echo "Starting OME Instance 2..."

docker run --rm -d \
  --name ome-test-2 \
  -p 2935:1935 \
  -p 8181:8081 \
  -v ./Server.xml:/opt/ovenmediaengine/bin/origin_conf/Server.xml \
  airensoft/ovenmediaengine:$OME_TAG

echo "Trying to start push..."

curl \
  -s \
  -X POST \
  -H "Content-Type: application/json" \
  -d @- \
   http://test:test@localhost:8081/v1/vhosts/default/apps/app:startPush > /dev/null << EOF
{
  "id": "stream1",
  "stream": {
    "name": "test",
    "variantNames": []
  },
  "protocol": "rtmp",
  "url": "rtmp://host.docker.internal:2935/app",
  "streamKey": "test"
}
EOF

echo "Push started."

curl \
  -s \
  -X POST \
  -H "Content-Type: application/json" \
  -d @- \
   http://test:test@localhost:8081/v1/vhosts/default/apps/app:pushes << EOF
{
  "id": "not-a-real-id"
}
EOF
Keukhan commented 9 months ago

https://github.com/AirenSoft/OvenMediaEngine/compare/0f3e09b8ed48...9627d4e731cd

@the-real-rusty-shackleford You've waited a long time. Last year I was so busy that I couldn't solve it. I finally solved the problem. The patch has been applied to the master branch. It will be reflected in the next release version.

Thank you so much for reporting the issue. happy new year :)

stale[bot] commented 7 months ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

the-real-rusty-shackleford commented 7 months ago

Bump. I'm not sure this has been released yet, so I haven't been able to test it.

the-real-rusty-shackleford commented 7 months ago

Oops, my mistake. I just tested this in 0.16.4 and it is working. Thanks!